<template>
  <div v-if="pageInitFlag">
    <div class="nur-doc-sheet">
      <div class="head-info">
        <div>入科时间:&nbsp;{{ this.entertime }}</div>
        <div>
          <el-date-picker
            v-model="queryDateTime"
            @change="queryDataArray"
            size="small"
            style="width: 340px;margin-right: 10px;"
            type="datetimerange"
            format="yyyy-MM-dd HH:mm"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-time="['07:00:00','07:00:00']">
          </el-date-picker>
          <el-button
            :loading="queryLoading"
            type="primary"
            size="small"
            style="margin-right: 20px"
            @click="queryDataArray"
          >查询
          </el-button>
          <span>是否开启脉率：</span>
          <el-switch
            v-model="pulseFlag"
            inactive-text="关闭"
            active-text="启动"
            active-value="true"
            inactive-value="false"
            active-color="#02538C"
            inactive-color="#B9B9B9"
            style="margin-right: 20px"
            class="switch-btn"
            @change="updatePulseFlag()"
          />
          <el-button
            size="small"
            @click="openSummaryOrSummarizePage('小结')"
          >小结
          </el-button>
          <el-button
            size="small"
            @click="openSummaryOrSummarizePage('总结')"
          >总结
          </el-button>
          <span style="margin: 0 20px 0 30px">
              打印初始页码：
              <el-input-number
                v-model="printParam.pageStartNumber"
                :min="1"
                :max="1000"
                size="small"
                style="width: 120px"
              ></el-input-number>
            </span>

          <el-button
            type="primary"
            size="small"
            @click="printAllButtonClick"
          >打印
          </el-button>
          <el-button
            type="primary"
            size="small"
            @click="processDate()"
          >同步
          </el-button>
        </div>
      </div>

      <el-table
        ref="mainTable"
        :data="dataArray"
        @row-dblclick="rowDbClick"
        :row-class-name="tableRowClassName"
        :cell-class-name="cellClassName"
        :stripe="true"
        style="width: 100%;"
        :header-cell-style="{
              background: '#F5F7FA',
              color: '#606266',
            }"
        :cell-style="cellStyle"
        height="600"
        @mouseover.native="handleMouseOver($event)"
        @mouseout.native="handleMouseOut"
      >
        <el-table-column label="操作" width="100" align="center" fixed>
          <template slot-scope="scope">
            <div style="text-align: center">
              <el-button
                v-if="!getRowEditPermission(scope.$index, 'editBtn') && scope.row.id"
                size="medium"
                type="text"
                @click="deleteButtonClick(scope.$index, scope.row)"
              >
                <i class="el-icon-delete" :style="{color: scope.row.flag?'white':'red'}"></i>
              </el-button>
              <el-button
                v-if="!getRowEditPermission(scope.$index,'editBtn') && !scope.row.flag"
                size="medium"
                type="text"
                icon="el-icon-edit"
                @click="rowDbClick(scope.row)"
                style="color: black"
              >
              </el-button>
              <el-button
                v-if="getRowEditPermission(scope.$index, 'editBtn')"
                size="medium"
                type="text"
                icon="el-icon-back"
                @click="reverseButtonClick(scope.$index)"
                style="color: green"
              ></el-button>
              <el-button
                v-if="getRowEditPermission(scope.$index, 'editBtn')"
                size="medium"
                type="text"
                icon="el-icon-check"
                @click="saveButtonClick(scope, scope.$index)"
                style="color: blue"
              ></el-button>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          label="日期"
          prop="date"
          width="80"
          align="center"
          fixed
        >
          <template slot-scope="scope">
            <el-date-picker
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.date"
              size="mini"
              type="date"
              :format="dateFormat"
              :value-format="dateFormat"
              @change="dateChange(scope.row)"
            />
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.date
              }}</span>
          </template>
        </el-table-column>
        <el-table-column
          fixed
          label="时间"
          width="45"
          prop="time"
          align="center"
          :resizable="false"
        >
          <template slot-scope="scope">
            <el-time-picker
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.time"
              size="mini"
              style="text-align: center"
              format="HH:mm"
              value-format="HH:mm"
              @change="timeChange(scope.row)"
            />
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.time
              }}</span>
          </template>
        </el-table-column>

        <el-table-column label="意识" align="center" width="52">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.consciousness"
              size="mini"
            >
              <el-option
                v-for="item in codeList.consciousness"
                :key="item.id"
                :label="item.name"
                :value="item.code"
              >
              </el-option>
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.consciousness
              }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="瞳孔"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column
            label="左"
            width="auto"
            align="center"
            header-align="center"
          >
            <el-table-column
              :label="'大小\n(mm)'"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilSizeLeft"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.pupil"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilSizeLeft
                  }}</span>
              </template>
            </el-table-column>
            <el-table-column
              label="对光反应"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilResponseLeft"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.light_reflection"
                    :key="item.id"
                    :label="item.name"
                    :value="item.code"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilResponseLeft
                  }}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column
            label="右"
            width="auto"
            align="center"
            header-align="center"
          >
            <el-table-column
              :label="'大小\n(mm)'"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilSizeRight"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.pupil"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilSizeRight
                  }}</span>
              </template>
            </el-table-column>
            <el-table-column
              label="对光反应"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilResponseRight"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.light_reflection"
                    :key="item.id"
                    :label="item.name"
                    :value="item.code"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilResponseRight
                  }}</span>
              </template>
            </el-table-column>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="生命体征"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column :label="'体温\n(℃)'" align="center" width="43">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.template"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                @blur="tiwenCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.template"></summary-style>
              </span>
            </template>
          </el-table-column>
          <el-table-column :label="'心率\n(次/分)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.hr"
                size="mini"
                style="text-align: center"
                @blur="xinlvCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.hr"></summary-style>
              </span>
            </template>
          </el-table-column>
          <el-table-column label="脉博(次/分)" align="center" width="43">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.pulse"
                size="mini"
                style="text-align: center"
                @blur="mailvCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.pulse"></summary-style>
              </span>
            </template>
          </el-table-column>
          <el-table-column label="呼吸(次/分)" align="center" width="45">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.br"
                size="mini"
                style="text-align: center"
                @blur="huxiCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.br"></summary-style>
              </span>
            </template>
          </el-table-column>
          <el-table-column label="有创血压(mmHg)" align="center" width="70">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.abp"
                size="mini"
                style="text-align: center"
                @blur="youchuangCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.abp"></summary-style>
              </span>
            </template>
          </el-table-column>
          <el-table-column label="无创血压(mmHg)" align="center" width="70">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.nbp"
                size="mini"
                style="text-align: center"
                @blur="wuchuangCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.nbp"></summary-style>
              </span>
            </template>
          </el-table-column>
          <el-table-column label="SpO₂(%)" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.spO2"
                size="mini"
                style="text-align: center"
                @blur="SPO2Check($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.spO2"></summary-style>
              </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="循环系统"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column label="心律" align="center" width="31">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.heartRhythm"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.heart_rate"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.heartRhythm
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'CVP\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.cvp"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
                @blur="cvpCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                <summary-style :filed-name="scope.row.cvp"></summary-style>
              </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="呼吸系统"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column :label="'吸氧/\n通气方式'" align="center" width="80">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.oxygenMode"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.inhale_oxygen_style"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.oxygenMode
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'氧流量\n(L/min)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.oxygenFlow"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
                @blur="yangliuliangCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.oxygenFlow
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="MODE" align="center" width="80">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.mode"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.mode"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.mode
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'FiO2\n(%)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.fio2"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
                @blur="FIO2Check($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.fio2
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'VT\n(ml)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.vt"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.vt
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'F\n(次/分)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.f"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.f
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'PC\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.pc"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.pc
                }}</span>
            </template>
          </el-table-column>

          <el-table-column :label="'PS\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.ps"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.ps
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'PEEP\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.peep"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.peep
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'IPAP\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.ipap"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.ipap
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="EPAP(cmH₂O)" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.epap"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.epap
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="吸痰" align="center" width="60">
            <template slot-scope="scope">
              <el-checkbox
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.sputum"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.sputum ? '✔' : ''
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="痰液分度" align="center" width="60">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.sputumInde"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.sputum_degree"
                  :key="item.id"
                  :label="item.name"
                  :value="item.name"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.sputumInde
                }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          :label="'血糖\n(mmol/L)'"
          align="center"
          :resizable="false"
          width="70"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.bloodGlucose"
              size="mini"
              style="text-align: center"
              @blur="xuetangCheck($event, scope)"
            />
            <span v-if="!getRowEditPermission(scope.$index)">
              <summary-style :filed-name="scope.row.bloodGlucose"></summary-style>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="翻身" width="100" align="center">
          <template slot-scope="scope">
            <el-checkbox
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.nurseActivity"
            />
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.nurseActivity ? '✔' : ''
              }}</span>
          </template>
        </el-table-column>
        <el-table-column label="体位" width="100" align="center">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.bodyPosition"
              size="mini"
              multiple
            >
              <el-option
                v-for="item in codeList.turn_over"
                :key="item.id"
                :label="item.code + '+' + item.name"
                :value="item.code"
              />
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.bodyPosition
              }}</span>
          </template>
        </el-table-column>

        <el-table-column label="护理" align="center">
          <el-table-column :label="'措施'" width="120" align="center">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.nurseMeasure"
                size="mini"
                multiple
              >
                <el-option
                  v-for="item in codeList.nurseMeasure"
                  :key="item.id"
                  :label="item.code + '+' + item.name"
                  :value="item.code"
                />
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.nurseMeasure
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="皮肤" width="120" align="center">
            <template slot-scope="scope">
              <el-cascader
                v-if="getRowEditPermission(scope.$index)"
                v-model="casValue"
                size="mini"
                :props="{multiple: true, checkStrictly: true,value:'code', label:'name'}"
                :options="casOptions"
                @change="casChange"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.nurseSkin
                }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="导管"
          align="center"
          header-align="center"
          width="200"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.pipeLength"
              style="text-align: left"
              type="textarea"
              :readonly="true"
              @input.native="textAreaChanging($event, scope.$index)"
              :autosize="{ minRows: 3, maxRows: 10 }"
              @dblclick.native.stop="selectTemplated(scope, scope.$index)"
            />
            <div
              style="text-align: left"
              v-if="
                    scope.row.pipeLength != '' && scope.row.pipeLength != null
                  "
            >
              <div
                v-if="!getRowEditPermission(scope.$index)"
                style="display: block; white-space: pre-line"
              >
                {{ scope.row.pipeLength.replace(/;/g, "\n") }}
              </div>
            </div>
            <div style="text-align: left" v-else>
              <div
                v-if="!getRowEditPermission(scope.$index)"
                style="display: block; white-space: pre-line"
              >
                {{ scope.row.pipeLength }}
              </div>
            </div>
          </template>
        </el-table-column>

        <el-table-column :label="'管路情况'" align="center">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.pipeReuse"
              size="mini"
            >
              <el-option
                v-for="item in codeList.pipe_use"
                :key="item.id"
                :label="item.name"
                :value="item.code"
              >
              </el-option>
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index)">{{ scope.row.pipeReuse }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="药物内容"
          align="center"
          header-align="center"
          width="200"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.medicineContent"
              type="textarea"
              :autosize="{ minRows: 3, maxRows: 10 }"
              @input.native="textAreaChanging($event, scope.$index)"
              @dblclick.native.stop="selectOrderName(scope.$index)"
            />
            <div style="text-align: left">
                  <span
                    v-if="!getRowEditPermission(scope.$index)"
                    style="white-space: pre-wrap; word-break: break-all"
                  >{{ scope.row.medicineContent }}</span
                  >
            </div>
          </template>
        </el-table-column>

        <el-table-column
          label="入量ml"
          align="center"
          header-align="center"
        >
          <el-table-column label="鼻饲/口服" align="center" header-align="center" width="90">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.noseMouth"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                    {{ scope.row.noseMouth | numFilter }}
                  </span>
            </template>
          </el-table-column>
          <el-table-column label="静脉" align="center" width="90">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.intravenous"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                    {{ scope.row.intravenous | numFilter }}
                  </span>
            </template>
          </el-table-column>
          <el-table-column label="其它" align="center" width="90">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.otherInNum"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                    {{ scope.row.otherInNum | numFilter }}
              </span>
            </template>
          </el-table-column>
          <el-table-column label="总入量" align="center" width="90">
            <template slot-scope="scope">
              <span>{{ scope.row.totalAmount | numFilter }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column
          label="出量ml"
          align="center"
          header-align="center"
        >
          <el-table-column
            label="小便"
            align="center"
            header-align="center"
            width="80"
          >
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.urine"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                    {{ scope.row.urine | numFilter }}
                  </span>
            </template>
          </el-table-column>
          <el-table-column
            label="大便"
            align="center"
            header-align="center"
            width="80"
          >
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.excrement"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
                    {{ scope.row.excrement | numFilter }}
                  </span>
            </template>
          </el-table-column>
          <el-table-column
            label="其它"
            align="center"
            header-align="center"
            width="100"
          >
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.otherOutNum"
                style="text-align: left"
                type="textarea"
                :readonly="true"
                @input.native="textAreaChanging($event, scope.$index)"
                :autosize="{ minRows: 3, maxRows: 10 }"
                @dblclick.native.stop="selectTemplateq(scope, scope.$index)"
              />
              <div
                style="text-align: left"
                v-if="
                      scope.row.otherOutNum != '' &&
                      scope.row.otherOutNum != 0 &&
                      scope.row.otherOutNum != null
                    "
              >
                <div
                  v-if="!getRowEditPermission(scope.$index)"
                  style="display: block; white-space: pre-line"
                >
                  {{ scope.row.otherOutNum.replace(/;/g, "\n") }}
                </div>
              </div>
              <div style="text-align: left" v-else>
                <div
                  style="display: block; white-space: pre-wrap"
                ></div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="总出量" align="center">
            <template slot-scope="scope">
                  <span
                    v-if="!getRowEditPermission(scope.$index) && scope.row.outputAmount"
                  >
                    {{ scope.row.outputAmount | numFilter }}
                  </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="病情观察、治疗、护理措施及效果"
          align="center"
          width="200"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.result"
              style="text-align: left"
              type="textarea"
              @input.native="textAreaChanging($event, scope.$index)"
              :autosize="{ minRows: 3, maxRows: 10 }"
              @dblclick.native.stop="selectTemplate(scope, scope.$index)"
            />
            <span
              v-if="!getRowEditPermission(scope.$index)"
              style="display: inline-block;text-align: left"
            >
              {{ scope.row.result }}
            </span>
          </template>
        </el-table-column>
        <el-table-column label="护士签名" align="center" width="80">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index, 'sign')"
              v-model="scope.row.signWorkNo"
              size="mini"
              filterable
              :filter-method="signFilter"
            >
              <el-option
                v-for="item in signOptions"
                :key="item.id"
                :value="item.login_name"
                :label="item.user_name"
              />
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index, 'sign')">
              <img
                :src="'/images/' + scope.row.signWorkNo.trim() + '.png'"
                style="width: 50px;height: 25px"
                v-if="!isNullEmpty(scope.row.signWorkNo)"
              >
              <!--              {{ scope.row.sign }}-->
            </span>
          </template>
        </el-table-column>
        <el-table-column label="接班签名" align="center" width="80">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index, 'secondSign')"
              v-model="scope.row.successorWorkNo"
              size="mini"
              filterable
              :filter-method="signFilter"
            >
              <el-option
                v-for="item in signOptions"
                :key="item.id"
                :value="item.login_name"
                :label="item.user_name"
              />
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index, 'secondSign')">
              <img
                :src="'/images/' + scope.row.successorWorkNo.trim() + '.png'"
                style="width: 50px;height: 25px"
                v-if="!isNullEmpty(scope.row.successorWorkNo)"
              >
              <!--              {{ scope.row.secondSign }}-->
            </span>
          </template>
        </el-table-column>
      </el-table>

      <div>
        <el-button
          slot="append"
          style="
              width: 100%;
              border-radius: 0;
              border-top: 0;
              border-left: 0;
              border-right: 0;
              position: sticky;
              z-index: 2;
              text-align: center;
            "
          @click="addEmptyRow"
        >点击追加一行
        </el-button>
      </div>
      <nursingPrompt :codeList="codeList"></nursingPrompt>
    </div>
    <!-- 三合一打印内容 ------------------------------------------------------>
    <div style="visibility: hidden; display: none">
      <div :id="printParam.title_id">
        <div style="line-height: 50px;display: flex;justify-content: center;">
          <div style="margin-right: 10px">
            <img src="@/icons/img/changzhi.png" style="width: 50px;height: 50px;"/>
          </div>
          <div style="font-size: 24px;font-weight: bold;">晋城市人民医院病重（病危）患者护理记录单</div>
        </div>
        <div style="display: flex;font-size: 15px; line-height: 24px;margin-top: 30px ">
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">科室：</span>
            <!--            {{ this.data.department_name }}-->
            重症医学科（白水院区）
          </div>
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">床号：</span>
            {{ this.data.bed_code }}
          </div>
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">姓名：</span>
            {{ this.data.name }}
          </div>
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">性别：</span>
            {{ this.data.sex }}
          </div>
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">年龄：</span>
            {{ this.$store.state.user.severFall.ageOrMonthAge }}
          </div>
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">住院号：</span>
            {{ this.data.visit_id === "" ? "" : this.data.visit_id }}
          </div>
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">入科时间：</span>
            {{ this.entertime }}
          </div>
          <div style="margin-right: 15px;">
            <span style="font-weight: bold">诊断：</span>
            {{ this.data.diagnosis_name }}
          </div>
        </div>

      </div>

      <el-table
        :id="printParam.table_id"
        :data="printArray"
        :cell-class-name="cellClassName"
        :cell-style="{'text-align':'center'}"
        style="width: 100%; display: block"
      >
        <el-table-column :label="'日期'" prop="date" align="left">
          <template slot-scope="scope">
            <span>{{ scope.row.date }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="'时间'" prop="time" align="left">
          <template slot-scope="scope">
            <span>{{ scope.row.time }}</span>
          </template>
        </el-table-column>

        <el-table-column :label="'意\n识'" align="left">
          <template slot-scope="scope">
            <span>{{ scope.row.consciousness }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="瞳孔"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column
            label="左"
            width="auto"
            align="center"
            header-align="center"
          >
            <el-table-column :label="'大小\n(mm)'" align="left">
              <template slot-scope="scope">
                <span>{{ scope.row.pupilSizeLeft }}</span>
              </template>
            </el-table-column>
            <el-table-column :label="'对\n光\n反\n应'" align="left">
              <template slot-scope="scope">
                <span>{{ scope.row.pupilResponseLeft }}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="右" align="left">
            <el-table-column :label="'大小\n(mm)'" align="left">
              <template slot-scope="scope">
                <span>{{ scope.row.pupilSizeRight }}</span>
              </template>
            </el-table-column>
            <el-table-column :label="'对\n光\n反\n应'" align="left">
              <template slot-scope="scope">
                <span>{{ scope.row.pupilResponseRight }}</span>
              </template>
            </el-table-column>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="生命体征"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column :label="'体温\n(℃)'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.template" :border="true"></summary-style>
            </template>
          </el-table-column>
          <el-table-column :label="'心\n率\n◠\n次\n/\n分\n◡'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.hr" :border="true"></summary-style>
            </template>
          </el-table-column>
          <el-table-column :label="'脉\n博\n◠\n次\n/\n分\n◡'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.pulse" :border="true"></summary-style>
            </template>
          </el-table-column>
          <el-table-column :label="'呼\n吸\n◠\n次\n/\n分\n◡'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.br" :border="true"></summary-style>
            </template>
          </el-table-column>
          <el-table-column :label="'有创血压\n(mmHg)'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.abp" :border="true"></summary-style>
            </template>
          </el-table-column>
          <el-table-column :label="'无创血压\n(mmHg)'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.nbp" :border="true"></summary-style>
            </template>
          </el-table-column>
          <el-table-column :label="'SpO₂\n(%)'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.spO2" :border="true"></summary-style>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column
          label="循环系统"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column :label="'心\n律'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.heartRhythm }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'CVP\n(cmH₂O)'" align="left">
            <template slot-scope="scope">
              <summary-style :filed-name="scope.row.cvp" :border="true"></summary-style>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="呼吸系统"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column :label="'吸\n氧\n/\n通\n气\n方\n式'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.oxygenMode }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'氧流量\n(L/min)'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.oxygenFlow }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'M\r\nO\r\nD\r\nE'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.mode
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'F\ni\nO\n2\n◠\n%\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.fio2 }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'V\nT\n◠\nm\nl\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.vt
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'F\n◠\n次\n/\n分\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.f
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'P\nC\n◠\nc\nm\nH₂\nO\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.pc
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'P\nS\n◠\nc\nm\nH₂\nO\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.ps
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'P\nE\nE\nP\n◠\nc\nm\nH₂\nO\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.peep
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'I\nP\nA\nP\n◠\nc\nm\nH₂\nO\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.ipap
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'E\nP\nA\nP\n◠\nc\nm\nH₂\nO\n◡'" align="left">
            <template slot-scope="scope">
              <span>{{
                  scope.row.epap
                }}</span>
            </template>
          </el-table-column>

          <el-table-column :label="'吸\n痰'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.sputum ? '✔' : '' }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'痰\n液\n分\n度'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.sputumInde }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          :label="'血\n糖\n◠\nm\nm\no\nl\n/\nL\n◡'"
          align="center"
          :resizable="false"
          width="52"
        >
          <template slot-scope="scope">
            <summary-style :filed-name="scope.row.bloodGlucose" :border="true"></summary-style>
          </template>
        </el-table-column>

        <el-table-column :label="'翻\n身'" align="left">
          <template slot-scope="scope">
            <span>{{ scope.row.nurseActivity ? '✔' : '' }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="'体\n位'" align="left">
          <template slot-scope="scope">
            <span style="display: inline-block; text-align: left">{{ scope.row.bodyPosition }}</span>
          </template>
        </el-table-column>

        <el-table-column label="护理" align="center">
          <el-table-column :label="'措\n施'">
            <template slot-scope="scope">
              <span style="display: inline-block; text-align: left">{{ scope.row.nurseMeasure }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'皮\n肤'" align="left">
            <template slot-scope="scope">
              <span style="display: inline-block; text-align: left">{{ scope.row.nurseSkin }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column :label="'导管'" align="left">
          <template slot-scope="scope">
            <span style="text-align: left;white-space: pre-line">
              {{ scope.row.pipeLength }}
            </span>
          </template>
        </el-table-column>
        <el-table-column :label="'管\n路\n情\n况'" align="center">
          <template slot-scope="scope">
            <div style="text-align: left">
              <span>{{ scope.row.pipeReuse }}</span>
            </div>
          </template>
        </el-table-column>


        <el-table-column :label="'药物内容'" align="left">
          <template slot-scope="scope">
            <div style="text-align: left">
              <span>{{ scope.row.medicineContent }}</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column :label="'入量(ml)'" align="center" header-align="center">
          <el-table-column :label="'鼻\n饲\n口\n服'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.noseMouth | numFilter }} </span>
            </template>
          </el-table-column>
          <el-table-column :label="'静\n脉'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.intravenous | numFilter }} </span>
            </template>
          </el-table-column>
          <el-table-column :label="'其\n它'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.otherInNum | numFilter }} </span>
            </template>
          </el-table-column>
          <el-table-column :label="'总\n入\n量'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.totalAmount | numFilter }} </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column label="出量ml" align="center">
          <template slot="header">
            <div>出量ml</div>
          </template>
          <el-table-column :label="'小\n便'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.urine | numFilter }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'大\n便'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.excrement | numFilter }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'其它'" align="left">
            <template slot-scope="scope">
              <div style="text-align: left;white-space: pre-line">
                <span>{{ scope.row.otherOutNum }}</span>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="'总\n出\n量'" align="left">
            <template slot-scope="scope">
              <span>{{ scope.row.outputAmount | numFilter }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column :label="'病情观察、治疗、护理措施及效果'" align="center">
          <template slot-scope="scope">
            <div style="text-align: left">
              <span>{{ scope.row.result }}</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column :label="'护\n士\n签\n名'">
          <template slot-scope="scope">
            <!--            <div style="white-space: nowrap;word-break: keep-all;text-align: left">-->
            <!--              {{ scope.row.sign }}-->
            <!--            </div>-->
            <!--            <div style="white-space: nowrap;word-break: keep-all;text-align: left">-->
            <!--              {{ scope.row.secondSign }}-->
            <!--            </div>-->
            <img
              :src="'/images/' + scope.row.signWorkNo.trim() + '.png'"
              style="width: 50px;height: 25px"
              v-if="!isNullEmpty(scope.row.signWorkNo)"
            >
            <img
              :src="'/images/' + scope.row.successorWorkNo.trim() + '.png'"
              style="width: 50px;height: 25px"
              v-if="!isNullEmpty(scope.row.successorWorkNo)"
            >
          </template>
        </el-table-column>
      </el-table>

      <nursingPrompt
        :codeList="codeList"
        :id="printParam.tail_id"
      >
        <div style="font-size: 17px;font-weight:bolder;margin-top: 40px">
          护士确认签名: <span
          style="display: inline-block;vertical-align: bottom;width: 500px;border-bottom: 1px solid #333"></span>
        </div>
      </nursingPrompt>
    </div>
    <!--医嘱列表-->
    <el-dialog
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      :destroy-on-close="true"
      width="70%"
    >
      <div slot="title" style="line-height: 24px;font-size: 18px; color: #303133;">
        <span>医嘱同步</span>
        <el-tooltip placement="right">
          <div slot="content" style="font-size: 16px">
            医嘱的执行流程是在his系统中进行的<br/>
            重症系统不参与医嘱执行流程，在此处展示从his同步过来的医嘱信息<br/>
            【同步】功能仅用于医嘱执行信息的再次确认并进入护理单，确保进入护理单数据的真实性，出入量统计将以<br/>
            护理单数据为准。<br/>
          </div>
          <i class="el-icon-question"/>
        </el-tooltip>
      </div>
      <orderList :rowIndex="orderIndex" style="height: auto"/>
    </el-dialog>
    <!--小结-->
    <el-dialog
      title="小结"
      :visible.sync="summaryDialog"
      width="30%"
    >
      <el-form :model="minSummaryData" label-width="110px">
        <el-form-item label="开始时间" prop="beginDate">
          <el-date-picker
            v-model="minSummaryData.beginDate"
            format="yyyy-MM-dd HH:mm"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="endDate">
          <el-date-picker
            v-model="minSummaryData.endDate"
            format="yyyy-MM-dd HH:mm"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="余量" prop="surplus">
          <el-input v-model="minSummaryData.surplus" style="width: 220px"/>
        </el-form-item>
        <el-form-item label="累加上次余量" prop="type">
          <el-radio-group v-model="minSummaryData.type">
            <el-radio :label="true">是</el-radio>
            <el-radio :label="false">否</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
          <el-button @click="summaryOrSummarizeCancel('小结')">取 消</el-button>
          <el-button type="primary" @click="summaryOrsummarizeClick('小结')"
          >确 定</el-button
          >
        </span>
    </el-dialog>
    <!--总结-->
    <el-dialog
      title="总结"
      :visible.sync="summarizeDialog"
      width="30%"
    >
      <el-form :model="summaryData" label-width="110px">
        <el-form-item label="开始时间" prop="beginDate">
          <el-date-picker
            v-model="summaryData.beginDate"
            format="yyyy-MM-dd HH:mm"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="endDate">
          <el-date-picker
            v-model="summaryData.endDate"
            format="yyyy-MM-dd HH:mm"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="余量" prop="surplus">
          <el-input v-model="summaryData.surplus" style="width: 220px"/>
        </el-form-item>
        <el-form-item label="累加上次余量" prop="type">
          <el-radio-group v-model="summaryData.type">
            <el-radio :label="true">是</el-radio>
            <el-radio :label="false">否</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
          <el-button @click="summaryOrSummarizeCancel('总结')">取 消</el-button>
          <el-button type="primary" @click="summaryOrsummarizeClick('总结')"
          >确 定</el-button
          >
        </span>
    </el-dialog>
    <!-- 出量-->
    <el-dialog
      title="出量"
      :visible.sync="summaryq"
      :close-on-click-modal="false"
    >
        <span slot="footer" class="dialog-footer">
          <el-button @click="summaryq = false"
          >取 消</el-button
          >
          <el-button type="primary" @click="summaryOrsummarizeqClick()"
          >确 定</el-button
          >
        </span>
      <el-form ref="form" :inline="true" :model="form" label-width="80px">
        <div
          v-for="(item, index) in form.list"
          :key="index"
        >
          <el-form-item
            label="出量名称"
            :prop="'list.' + index + '.outPutName'"
            :rules="{
                required: true,
                message: '出量名称不能为空',
                trigger: 'blur',
              }"
          >
            <el-select
              v-model="item.outPutName"
              filterable
            >
              <el-option
                v-for="item in templateType"
                :key="item.id"
                :value="item.template_item_name"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            label="出量(ml)"
            :prop="'list.' + index + '.outPutValue'"
            :rules="[
                { required: true, message: '出量值不能为空', trigger: 'blur' },
              ]"
          >
            <el-input
              v-model="item.outPutValue"
              oninput="value=value.replace(/[^0-9.]/g,'')"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <i
              v-if="index + 1 == form.list.length"
              @click="addItem"
              class="el-icon-circle-plus-outline"
            ></i>
            <i
              @click="deleteItem(item, index,form.list.length)"
              class="el-icon-remove-outline"
            ></i>
          </el-form-item>
        </div>
      </el-form>
    </el-dialog>
    <!-- 导管-->
    <el-dialog
      title="导管"
      :visible.sync="summaryd"
      :close-on-click-modal="false"
      class="pipe-dialog"
      style="margin: 0 auto;"
    >
      <el-form ref="form" :inline="true" :model="form" label-width="100px">
        <div
          v-for="(item, index) in form.pipeLengthList"
          :key="index"
          style="margin: 20px 0 0"
        >
          <el-form-item
            label="导管名称"
            :prop="'pipeLengthList.' + index + '.pipeName'"
            :rules="{
                required: form.pipeLengthList.length != 1 ? true : false,
                message: '导管名称不能为空',
                trigger: 'blur',
              }"
          >
            <el-select
              v-model="item.pipeName"
              filterable
              @change="throughputd(item)"
            >
              <el-option
                v-for="item in templateTypes"
                :key="item.id"
                :value="item.template_item_name"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            label="外露\置入"
            :prop="'pipeLengthList.' + index + '.exposure'"
          >
            <el-select v-model="item.exposure">
              <el-option
                v-for="item in translate"
                :key="item.id"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            label="长度(cm)"
            :prop="'pipeLengthList.' + index + '.pipeLength'"
          >
            <el-input
              v-model="item.pipeLength"
              style="width: 200px"
              oninput="value=value.replace(/[^0-9.]/g,'')"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="是否通畅"
            :prop="'pipeLengthList.' + index + '.unobstructed'"
          >
            <el-select
              v-model="item.unobstructed"
            >
              <el-option
                v-for="item in codeList.unobstructed"
                :key="item.id"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            label="部位"
            :prop="'pipeLengthList.' + index + '.parts'"
          >
            <el-select
              v-model="item.parts"
              filterable
            >
              <el-option
                v-for="item in codeList.body_parts"
                :key="item.id"
                :value="item.name"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            label="引流液颜色"
            :prop="'pipeLengthList.' + index + '.liquidColor'"
          >
            <el-select
              v-model="item.liquidColor"
              filterable
            >
              <el-option
                v-for="item in codeList.drainage_color"
                :key="item.id"
                :value="item.name"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <i
              v-if="index + 1 == form.pipeLengthList.length"
              @click="addItemd"
              class="el-icon-circle-plus-outline"
            ></i>
            <i
              @click="deleteItemd(item, index, form.pipeLengthList.length)"
              class="el-icon-remove-outline"
            ></i>
          </el-form-item>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
          <el-button @click="summaryd = false"
          >取 消</el-button
          >
          <el-button type="primary" @click="summaryOrsummarizedClick()"
          >确 定</el-button
          >
        </span>
    </el-dialog>
    <!-- 护理模板 -->
    <el-dialog
      title="护理模板选择"
      :visible.sync="nursingMeasuresDialog"
      :close-on-click-modal="false"
    >
      <nursingTemplate :rowIndex="rowIndex" :patientId="data.patient_id"/>
    </el-dialog>
    <!-- 同步 -->
    <el-dialog
      title="同步生命体征"
      :visible.sync="synchronizeDialog"
      width="30%"
      :close-on-click-modal="false"
      class="sync-dialog"
    >
      <div>
        <span class="label">开始时间：</span>
        <el-date-picker
          v-model="synchronizeBeginDate"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetime"
          size="small"
          placeholder="选择日期时间"
          :disabled="statusover"
        >
        </el-date-picker>
      </div>
      <div>
        <span class="label">结束时间：</span>
        <el-date-picker
          v-model="synchronizeEndDate"
          format="yyyy-MM-dd HH:mm:ss"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetime"
          size="small"
          placeholder="选择日期时间"
          :disabled="statusover"
        >
        </el-date-picker>
      </div>
      <div>
        <span class="label">频率(min/次)：</span>
        <el-input
          name="peep"
          v-model="frequency"
          size="small"
          width="220"
          :disabled="statusover"
        />
      </div>
      <div class="sync-row">
        <span class="label">状态：</span>
        <el-switch
          v-model="statusover"
          class="switch-btn"
          inactive-text="关闭"
          active-text="启动"
          active-color="#02538C"
          inactive-color="#B9B9B9"
          @change="syncStatechange()"
        />
      </div>
      <span slot="footer" class="dialog-footer">
          <el-button @click="synchronizeSaveCancel()">取 消</el-button>
          <el-button type="primary" @click="synchronizeSave()">确 定</el-button>
        </span>
    </el-dialog>
    <!-- 弹出提示框 -->
    <el-dialog
      :visible.sync="hoverDialogVisible"
      width="30%"
      :before-close="handleClose2"
    >
      <span>{{ hoverRowInfo }}</span>
      <span style="display: flex;justify-content: flex-end;">
      <el-button @click="HistoryUpdate">历史修改</el-button>
      </span>
      <span slot="footer" class="dialog-footer">
      <el-button @click="hoverDialogVisible = false">关闭</el-button>
            </span>
    </el-dialog>

    <!-- 弹出提示框 -->
    <el-dialog
      title="历史修改"
      :visible.sync="hoverDetailsDialogVisible"
      width="100%"
      :before-close="handleClose3"
    >
      <el-table
        ref="mainTable"
        :data="updateLogArr"
        @row-dblclick="rowDbClick"
        :row-class-name="tableRowClassName"
        :cell-class-name="cellClassName"
        :stripe="true"
        style="width: 100%;"
        :header-cell-style="{
        background: '#F5F7FA',
        color: '#606266',
      }"
        :cell-style="cellStyle"
        height="600"
      >
        <!-- 添加 userName 列 -->
        <el-table-column label="修改人" prop="userName" width="100" align="center" fixed>
          <template slot-scope="scope">
            <span>{{ scope.row.userName }}</span>
          </template>
        </el-table-column>

        <!-- 添加 updateTime 列 -->
        <el-table-column label="更新时间" prop="updateTime" width="120" align="center" fixed>
          <template slot-scope="scope">
            <span>{{ formatDate(scope.row.updateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="日期"
          prop="date"
          width="80"
          align="center"
          fixed
        >
          <template slot-scope="scope">
            <el-date-picker
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.date"
              size="mini"
              type="date"
              :format="dateFormat"
              :value-format="dateFormat"
              @change="dateChange(scope.row)"
            />
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.date
              }}</span>
          </template>
        </el-table-column>
        <el-table-column
          fixed
          label="时间"
          width="45"
          prop="time"
          align="center"
          :resizable="false"
        >
          <template slot-scope="scope">
            <el-time-picker
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.time"
              size="mini"
              style="text-align: center"
              format="HH:mm"
              value-format="HH:mm"
              @change="timeChange(scope.row)"
            />
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.time
              }}</span>
          </template>
        </el-table-column>

        <el-table-column label="意识" align="center" width="52">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.consciousness"
              size="mini"
            >
              <el-option
                v-for="item in codeList.consciousness"
                :key="item.id"
                :label="item.name"
                :value="item.code"
              >
              </el-option>
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.consciousness
              }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="瞳孔"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column
            label="左"
            width="auto"
            align="center"
            header-align="center"
          >
            <el-table-column
              :label="'大小\n(mm)'"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilSizeLeft"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.pupil"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilSizeLeft
                  }}</span>
              </template>
            </el-table-column>
            <el-table-column
              label="对光反应"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilResponseLeft"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.light_reflection"
                    :key="item.id"
                    :label="item.name"
                    :value="item.code"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilResponseLeft
                  }}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column
            label="右"
            width="auto"
            align="center"
            header-align="center"
          >
            <el-table-column
              :label="'大小\n(mm)'"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilSizeRight"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.pupil"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilSizeRight
                  }}</span>
              </template>
            </el-table-column>
            <el-table-column
              label="对光反应"
              width="60"
              align="center"
              header-align="center"
            >
              <template slot-scope="scope">
                <el-select
                  v-if="getRowEditPermission(scope.$index)"
                  v-model="scope.row.pupilResponseRight"
                  size="mini"
                >
                  <el-option
                    v-for="item in codeList.light_reflection"
                    :key="item.id"
                    :label="item.name"
                    :value="item.code"
                  >
                  </el-option>
                </el-select>
                <span v-if="!getRowEditPermission(scope.$index)">{{
                    scope.row.pupilResponseRight
                  }}</span>
              </template>
            </el-table-column>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="生命体征"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column :label="'体温\n(℃)'" align="center" width="43">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.template"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                @blur="tiwenCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.template"></summary-style>
        </span>
            </template>
          </el-table-column>
          <el-table-column :label="'心率\n(次/分)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.hr"
                size="mini"
                style="text-align: center"
                @blur="xinlvCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.hr"></summary-style>
        </span>
            </template>
          </el-table-column>
          <el-table-column label="脉博(次/分)" align="center" width="43">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.pulse"
                size="mini"
                style="text-align: center"
                @blur="mailvCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.pulse"></summary-style>
        </span>
            </template>
          </el-table-column>
          <el-table-column label="呼吸(次/分)" align="center" width="45">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.br"
                size="mini"
                style="text-align: center"
                @blur="huxiCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.br"></summary-style>
        </span>
            </template>
          </el-table-column>
          <el-table-column label="有创血压(mmHg)" align="center" width="70">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.abp"
                size="mini"
                style="text-align: center"
                @blur="youchuangCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.abp"></summary-style>
        </span>
            </template>
          </el-table-column>
          <el-table-column label="无创血压(mmHg)" align="center" width="70">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.nbp"
                size="mini"
                style="text-align: center"
                @blur="wuchuangCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.nbp"></summary-style>
        </span>
            </template>
          </el-table-column>
          <el-table-column label="SpO₂(%)" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.spO2"
                size="mini"
                style="text-align: center"
                @blur="SPO2Check($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.spO2"></summary-style>
        </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="循环系统"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column label="心律" align="center" width="31">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.heartRhythm"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.heart_rate"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.heartRhythm
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'CVP\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.cvp"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
                @blur="cvpCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
          <summary-style :filed-name="scope.row.cvp"></summary-style>
        </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="呼吸系统"
          width="auto"
          align="center"
          header-align="center"
        >
          <el-table-column :label="'吸氧/\n通气方式'" align="center" width="80">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.oxygenMode"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.inhale_oxygen_style"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.oxygenMode
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'氧流量\n(L/min)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.oxygenFlow"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
                @blur="yangliuliangCheck($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.oxygenFlow
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="MODE" align="center" width="80">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.mode"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.mode"
                  :key="item.id"
                  :label="item.name"
                  :value="item.code"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.mode
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'FiO2\n(%)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.fio2"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
                @blur="FIO2Check($event, scope)"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.fio2
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'VT\n(ml)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.vt"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.vt
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'F\n(次/分)'" align="center" width="50">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.f"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.f
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'PC\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.pc"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.pc
                }}</span>
            </template>
          </el-table-column>

          <el-table-column :label="'PS\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.ps"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.ps
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'PEEP\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.peep"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.peep
                }}</span>
            </template>
          </el-table-column>
          <el-table-column :label="'IPAP\n(cmH₂O)'" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.ipap"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.ipap
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="EPAP(cmH₂O)" align="center" width="60">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.epap"
                size="mini"
                style="text-align: center"
                oninput="value=value.replace(/[^0-9]/g,'')"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.epap
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="吸痰" align="center" width="60">
            <template slot-scope="scope">
              <el-checkbox
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.sputum"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.sputum ? '✔' : ''
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="痰液分度" align="center" width="60">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.sputumInde"
                size="mini"
              >
                <el-option
                  v-for="item in codeList.sputum_degree"
                  :key="item.id"
                  :label="item.name"
                  :value="item.name"
                >
                </el-option>
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.sputumInde
                }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          :label="'血糖\n(mmol/L)'"
          align="center"
          :resizable="false"
          width="70"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.bloodGlucose"
              size="mini"
              style="text-align: center"
              @blur="xuetangCheck($event, scope)"
            />
            <span v-if="!getRowEditPermission(scope.$index)">
        <summary-style :filed-name="scope.row.bloodGlucose"></summary-style>
      </span>
          </template>
        </el-table-column>
        <el-table-column label="翻身" width="100" align="center">
          <template slot-scope="scope">
            <el-checkbox
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.nurseActivity"
            />
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.nurseActivity ? '✔' : ''
              }}</span>
          </template>
        </el-table-column>
        <el-table-column label="体位" width="100" align="center">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.bodyPosition"
              size="mini"
              multiple
            >
              <el-option
                v-for="item in codeList.turn_over"
                :key="item.id"
                :label="item.code + '+' + item.name"
                :value="item.code"
              />
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index)">{{
                scope.row.bodyPosition
              }}</span>
          </template>
        </el-table-column>

        <el-table-column label="护理" align="center">
          <el-table-column :label="'措施'" width="120" align="center">
            <template slot-scope="scope">
              <el-select
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.nurseMeasure"
                size="mini"
                multiple
              >
                <el-option
                  v-for="item in codeList.nurseMeasure"
                  :key="item.id"
                  :label="item.code + '+' + item.name"
                  :value="item.code"
                />
              </el-select>
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.nurseMeasure
                }}</span>
            </template>
          </el-table-column>
          <el-table-column label="皮肤" width="120" align="center">
            <template slot-scope="scope">
              <el-cascader
                v-if="getRowEditPermission(scope.$index)"
                v-model="casValue"
                size="mini"
                :props="{multiple: true, checkStrictly: true,value:'code', label:'name'}"
                :options="casOptions"
                @change="casChange"
              />
              <span v-if="!getRowEditPermission(scope.$index)">{{
                  scope.row.nurseSkin
                }}</span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="导管"
          align="center"
          header-align="center"
          width="200"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.pipeLength"
              style="text-align: left"
              type="textarea"
              :readonly="true"
              @input.native="textAreaChanging($event, scope.$index)"
              :autosize="{ minRows: 3, maxRows: 10 }"
              @dblclick.native.stop="selectTemplated(scope, scope.$index)"
            />
            <div
              style="text-align: left"
              v-if="
              scope.row.pipeLength != '' && scope.row.pipeLength != null
            "
            >
              <div
                v-if="!getRowEditPermission(scope.$index)"
                style="display: block; white-space: pre-line"
              >
                {{ scope.row.pipeLength.replace(/;/g, "\n") }}
              </div>
            </div>
            <div style="text-align: left" v-else>
              <div
                v-if="!getRowEditPermission(scope.$index)"
                style="display: block; white-space: pre-line"
              >
                {{ scope.row.pipeLength }}
              </div>
            </div>
          </template>
        </el-table-column>

        <el-table-column :label="'管路情况'" align="center">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.pipeReuse"
              size="mini"
            >
              <el-option
                v-for="item in codeList.pipe_use"
                :key="item.id"
                :label="item.name"
                :value="item.code"
              >
              </el-option>
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index)">{{ scope.row.pipeReuse }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="药物内容"
          align="center"
          header-align="center"
          width="200"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.medicineContent"
              type="textarea"
              :autosize="{ minRows: 3, maxRows: 10 }"
              @input.native="textAreaChanging($event, scope.$index)"
              @dblclick.native.stop="selectOrderName(scope.$index)"
            />
            <div style="text-align: left">
            <span
              v-if="!getRowEditPermission(scope.$index)"
              style="white-space: pre-wrap; word-break: break-all"
            >{{ scope.row.medicineContent }}</span
            >
            </div>
          </template>
        </el-table-column>

        <el-table-column
          label="入量ml"
          align="center"
          header-align="center"
        >
          <el-table-column label="鼻饲/口服" align="center" header-align="center" width="90">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.noseMouth"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
              {{ scope.row.noseMouth | numFilter }}
            </span>
            </template>
          </el-table-column>
          <el-table-column label="静脉" align="center" width="90">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.intravenous"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
              {{ scope.row.intravenous | numFilter }}
            </span>
            </template>
          </el-table-column>
          <el-table-column label="其它" align="center" width="90">
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.otherInNum"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
              {{ scope.row.otherInNum | numFilter }}
        </span>
            </template>
          </el-table-column>
          <el-table-column label="总入量" align="center" width="90">
            <template slot-scope="scope">
              <span>{{ scope.row.totalAmount | numFilter }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column
          label="出量ml"
          align="center"
          header-align="center"
        >
          <el-table-column
            label="小便"
            align="center"
            header-align="center"
            width="80"
          >
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.urine"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
              {{ scope.row.urine | numFilter }}
            </span>
            </template>
          </el-table-column>
          <el-table-column
            label="大便"
            align="center"
            header-align="center"
            width="80"
          >
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.excrement"
                size="mini"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                style="text-align: center"
              />
              <span v-if="!getRowEditPermission(scope.$index)">
              {{ scope.row.excrement | numFilter }}
            </span>
            </template>
          </el-table-column>
          <el-table-column
            label="其它"
            align="center"
            header-align="center"
            width="100"
          >
            <template slot-scope="scope">
              <el-input
                v-if="getRowEditPermission(scope.$index)"
                v-model="scope.row.otherOutNum"
                style="text-align: left"
                type="textarea"
                :readonly="true"
                @input.native="textAreaChanging($event, scope.$index)"
                :autosize="{ minRows: 3, maxRows: 10 }"
                @dblclick.native.stop="selectTemplateq(scope, scope.$index)"
              />
              <div
                style="text-align: left"
                v-if="
                scope.row.otherOutNum != '' &&
                scope.row.otherOutNum != 0 &&
                scope.row.otherOutNum != null
              "
              >
                <div
                  v-if="!getRowEditPermission(scope.$index)"
                  style="display: block; white-space: pre-line"
                >
                  {{ scope.row.otherOutNum.replace(/;/g, "\n") }}
                </div>
              </div>
              <div style="text-align: left" v-else>
                <div
                  style="display: block; white-space: pre-wrap"
                ></div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="总出量" align="center">
            <template slot-scope="scope">
            <span
              v-if="!getRowEditPermission(scope.$index) && scope.row.outputAmount"
            >
              {{ scope.row.outputAmount | numFilter }}
            </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column
          label="病情观察、治疗、护理措施及效果"
          align="center"
          width="200"
        >
          <template slot-scope="scope">
            <el-input
              v-if="getRowEditPermission(scope.$index)"
              v-model="scope.row.result"
              style="text-align: left"
              type="textarea"
              @input.native="textAreaChanging($event, scope.$index)"
              :autosize="{ minRows: 3, maxRows: 10 }"
              @dblclick.native.stop="selectTemplate(scope, scope.$index)"
            />
            <span
              v-if="!getRowEditPermission(scope.$index)"
              style="display: inline-block;text-align: left"
            >
        {{ scope.row.result }}
      </span>
          </template>
        </el-table-column>
        <el-table-column label="护士签名" align="center" width="80">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index, 'sign')"
              v-model="scope.row.signWorkNo"
              size="mini"
              filterable
              :filter-method="signFilter"
            >
              <el-option
                v-for="item in signOptions"
                :key="item.id"
                :value="item.login_name"
                :label="item.user_name"
              />
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index, 'sign')">
        <img
          :src="'/images/' + scope.row.signWorkNo.trim() + '.png'"
          style="width: 50px;height: 25px"
          v-if="!isNullEmpty(scope.row.signWorkNo)"
        >
              <!--              {{ scope.row.sign }}-->
      </span>
          </template>
        </el-table-column>
        <el-table-column label="接班签名" align="center" width="80">
          <template slot-scope="scope">
            <el-select
              v-if="getRowEditPermission(scope.$index, 'secondSign')"
              v-model="scope.row.successorWorkNo"
              size="mini"
              filterable
              :filter-method="signFilter"
            >
              <el-option
                v-for="item in signOptions"
                :key="item.id"
                :value="item.login_name"
                :label="item.user_name"
              />
            </el-select>
            <span v-if="!getRowEditPermission(scope.$index, 'secondSign')">
        <img
          :src="'/images/' + scope.row.successorWorkNo.trim() + '.png'"
          style="width: 50px;height: 25px"
          v-if="!isNullEmpty(scope.row.successorWorkNo)"
        >
      </span>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
      <el-button @click="hoverDetailsDialogVisible = false">关闭</el-button>
    </span>
    </el-dialog>
  </div>
</template>

<script>
import {jyxdPrint} from "@/utils/jyxd-printer";
import nursingPrompt from "@/views/nursingDocument/combinedSheetPrompt.vue";
import orderList from "@/views/nursingDocument/orderList.vue";
import {dateUtils} from "@/utils/dateUtils";
import nursingTemplate from "@/views/nursingDocument/nursingTemplate.vue";
import {Message} from "element-ui";
import {dateCompare, isNullEmpty, isNumber} from "@/utils/utils";

import {
  getCombinedCodeList,
  getCombinedSheetDelete,
  getCombinedSheetInsert,
  getCombinedSheetList,
  getCombinedSheetSummaryOrSummarize,
  getCommonSettingByPatientId,
  getListlei,
  getUserListByUserTypegetNurseList,
  insertFlag,
  nurseRecordFormOutPutqueryList,
  nurseRecordFormPipeLengthQueryList,
  NursingUpdateOnOrOff,
  openPulseRecord,
  queryDataMaibo,
} from "@/api/table";
import SummaryStyle from "@/views/nursingDocument/summaryStyle";
import {getNurLog, getNurLogs} from "@/api/ZnurUpdateLog";

export default {
  components: {
    SummaryStyle,
    nursingPrompt,
    orderList,
    nursingTemplate,
  },
  data() {
    return {
      updateLogArr: [],
      hoverDetailsDialogVisible: false,
      hoverTimer: null,
      hoverDialogVisible: false,
      hoverRowInfo: '',
      hoverRowIndex: -1,
      historyRowId: '',
      tempDate: '',
      tempTime: '',
      loginInfo: '', //登录信息
      editPermission: 0, //0均可编辑；1可编辑非护士签名外的其它数据；2只可编辑接班签名
      casValue: '',
      casValueEnd: '',
      casOptions: [
        {
          code: '×',
          name: '×',
          children: [],
        },
        {
          code: '✔',
          name: '✔',
          children: [],
        },
      ],
      codeList: {}, //全部下拉选项字典
      settingName: "combinedSheetSetting", //保存设置之名字
      summaryDialog: false,
      summarizeDialog: false,
      summaryq: false,
      summaryd: false,
      summaryData: {
        beginDate: "", //总结开始时间
        endDate: "", //总结结束时间
        surplus: 0, //余量值
        type: true //是否累加
      },
      minSummaryData: {
        beginDate: "", //小结开始时间
        endDate: "", //小结结束时间
        surplus: 0,//余量值
        type: true //是否累加
      },
      queryDateTime: [], //查询日期时间范围
      queryBeginDate: "", //查询开始时间
      queryEndDate: "", //查询结束时间
      loading: false, //查询中
      entertime: "", //入科时间
      orderID: "",
      orderTime: "",
      nursingMeasuresDialog: false, //护理措施弹出标识
      synchronizeDialog: false, //同步生命体征标识
      synchronizeBeginDate: "",
      synchronizeEndDate: "",
      frequency: "",
      outPutName: "",
      outPutValue: "",
      panto: [],
      outPutDictionaryId: "",
      arrTypelist: [],
      templateType: [],
      templateTypes: [],
      statusover: false,
      form: {
        rowId: "",
        patientId: "",
        pipeLengthList: [
          {
            pipeName: "",
            exposure: "",
            pipeLength: "",
            unobstructed: "",
            parts: '',
            liquidColor: ''
          },
        ],
        list: [
          {
            outPutName: "",
            outPutValue: "",
            outPutDictionaryId: ""
          },
        ],
      },
      translate: [{
        id: "0",
        label: "",
        value: "",
      }, {
        id: "1",
        label: "外露",
        value: "外露",
      }, {
        id: "2",
        label: "置入",
        value: "置入",
      }],
      idsss: "",
      orderIndex: "", //行数据
      selectTime: true, //控制选择的时间不能超过当前时间
      age: "",
      tableHeight: 1000,
      dialogVisible: false,
      optionIdb: [],
      start_time: "",
      end_time: "",
      rowIndex: "",
      printParam: {
        table_id: "mytable", //表实体div id，<el-table>表内容不能全空，至少有一行，即使是空行
        title_id: "myheader", //表前抬头栏div 的id，如果没有或不需打印，去除此变量或置空或置"无"
        tail_id: "mytail", //表后签字栏div 的id，如果没有或不需打印，去除此变量或置空或置"无"
        page_rows: 18, //首页行数，0，表示不分页
        second_rows: 20, //首页之外各页的行数，只在首页打印抬头的话首页行数和其它页行数会不同
        paper_height: "1450", //纸张长度，设为大于500的值表示自动按纸张长度分页，设其它值都按每页行数分页。
        //例如A4纸长度大概在1040-1400之间。
        //纸张长度分页优于按行数分页，设置纸张长度后，每页行数的设置被忽略不用。
        //严重折行的表格按纸张长度分页可能会造成分页错误，预览到错误后可以调整纸张长度纠正。
        paper_width: "2140",
        pageStartNumber: 1, //起始页码
        paging: true, //是否显示页面角标
        table_head: "", //非el-table表的表头id，表前部不变部分，用tbody id=>  </tbody>括起来
        table_body: "text-align: left", //非el-table表的表体id，填充数据部分，用<tbody id=>  </tbody>括起来
        table_foot: "", //非el-table表的表脚id，表里不变部分，用<tbody id=>  </tbody>括起来
        button: "", //是否打印按钮，置"button"或"打印"表示输出按钮，去除此变量或置空将隐藏所有按钮
        title: "", //是否每页都要页面抬头，置"first"或"首页"表示只有首页打印抬头，去除此变量或置空所有页面都有抬头
        tail: "", //是否每页都要页面签字栏，置"first"或"首页"表示只有首页打印签字栏，去除此变量或置空所有页面都有签字栏
        blank: 0, //打印空表页数，空表保留所有上述格式，内容为空。0表示打印实际数据表。
        hidden_col: "", //隐藏列号范围，如 "0,2-4,9"，列号从0起计，去除此变量或置空表示打印所有列。复杂表头暂不支持列隐藏。
        preview: "预览", //是否仅仅预览？置"预览"表示仅展示在屏幕上，置空表示表示直接调用print()。
        thead_style: "font-size:13px;white-space: pre-line;",
        tbody_style: "font-size:13px",
        tail_style: "",
        title_font: "Arial",
        title_font_size: 15,
        tail_font_size: 13,
        tail_font: "Arial",
        thead_font: "宋体",
        thead_font_size: 13,
        tbody_font_size: 13,
        tbody_font: "宋体",
        title_style: "",
        tfoot_style: "",
        col_width: [
          {col: 0, width: 110}, //日期
          {col: 1, width: 70}, //时间
          {col: 2, width: 50}, // 意识
          {col: 3, width: 60}, //大小
          {col: 4, width: 50}, //对光反应
          {col: 5, width: 60}, //大小
          {col: 6, width: 50}, //对光反应
          {col: 7, width: 75}, //体温
          {col: 8, width: 70}, //心率
          {col: 9, width: 70}, //脉搏
          {col: 10, width: 70}, //呼吸
          {col: 11, width: 90}, //有创
          {col: 12, width: 90}, //无创
          {col: 13, width: 70}, //spo2
          {col: 14, width: 50}, //心律
          {col: 15, width: 80}, //cvp
          {col: 16, width: 50}, //吸氧/通气方式
          {col: 17, width: 85}, //氧流量
          {col: 18, width: 50}, //MODE
          {col: 19, width: 50}, //FIO2
          {col: 20, width: 50}, //VT
          {col: 21, width: 50}, //F
          {col: 22, width: 50}, //PC
          {col: 23, width: 50}, //PS
          {col: 24, width: 50}, //PEEP
          {col: 25, width: 50}, //IPAPPS
          {col: 26, width: 50}, //EPAP
          {col: 27, width: 50}, //吸痰
          {col: 28, width: 60}, //痰液分度
          {col: 29, width: 70}, //血糖
          {col: 30, width: 50}, //翻身
          {col: 31, width: 60}, //体位
          {col: 32, width: 70}, //措施
          {col: 33, width: 70}, //皮肤
          {col: 34, width: 160}, //导管长度
          {col: 35, width: 50}, //管路情况
          {col: 36, width: 150}, //药物内容
          {col: 37, width: 60}, //鼻饲/口服
          {col: 38, width: 60}, //静脉
          {col: 39, width: 60}, //入量其它
          {col: 40, width: 60}, //总入量
          {col: 41, width: 60}, //小便
          {col: 42, width: 60}, //大便
          {col: 43, width: 160}, //其他
          {col: 44, width: 60}, //总出量
          {col: 45, width: 220}, //病情观察、治疗、护理措施及效果
          {col: 46, width: 75}, //护士签名
        ],
        divide_cols: [31, 32, 33, 34, 35, 36, 43, 45], //允许拆分的列号
        debug: "no" //不打印debug信息
      },
      user_name: "",
      associatedTable: "",
      data: {}, //患者信息
      //表格数据
      //-----------打印用
      printArray: [],
      //-----------------编辑用
      dataArray: [],
      queryLoading: false,
      editIndex: -1, //编辑行号，从0开始
      editIndexs: -1,
      lastRowData: {}, //保存回滚值
      editRowHeight: 28, //行高
      revisableDays: 2, //指定多少天前的数据被保护，不允许修改删除
      aheadMinutes: 10, //允许提前多少分钟录入数据，即可以选择未来的时刻
      ignoredKeys: ["index", "date", "time", "signature", "secondSign"], //判是否空行时忽略不计的变量名
      //值变化的列
      dateFormat: "yyyy-MM-dd", //显示日期格式
      arrUserName: [],
      signOptions: [],
      editIndex1: -1, //自定义用
      actionColumnFlag: true,
      start: 1, // 默认显示第几页
      totalCount: 0, // 总条数，根据接口获取数据长度(注意 : 这里不能为空)
      pgeSizes: [10, 20, 30, 40], // 个数选择器（可修改）
      PageSize: 10, // 默认每页显示的条数（可修改）
      pageFlag: false,
      addFlag: true,
      pulseFlag: true, //脉搏开启状态
      pageInitFlag: false,
    };
  },
  mounted() {
    this.initData();

    //获取签名列表
    getUserListByUserTypegetNurseList({
      deptCode: this.$store.state.user.loginInfo.deptCode
    }).then((res) => {
      this.arrUserName = res.data;
      Object.assign(this.signOptions, res.data);
    });

    eventBus.$off("selectOrName");
    eventBus.$off("selectTemplateResult");
    //药物名称赋值
    eventBus.$on("selectOrName", (row, xin) => {
      this.dataArray[row.rowIndex].medicineContent = row.val;
      this.orderID = xin[0];
      this.orderTime = xin[1];
      this.dialogVisible = false;
    });
    //护理措施
    eventBus.$on("selectTemplateResult", (row) => {
      if (this.dataArray[row.rowIndex].result) {
        this.dataArray[row.rowIndex].result += '\n' + row.val;
      } else {
        this.dataArray[row.rowIndex].result = row.val;
      }
      this.nursingMeasuresDialog = false;
    });
    this.pageInitFlag = true;
    this.selectTypeList();
    window.addEventListener('keydown', this.handleKeyDown);
  },
  beforeDestroy() {
    window.removeEventListener('keydown', this.handleKeyDown);
  },
  computed: {
    getData() {
      return this.$store.state.user.severFall;
    },
  },
  watch: {
    getData() {
      this.data = this.$store.state.user.severFall;
      //判断跳转新旧页面
      if (this.data.sync_new_or_old_vital_sign != "false") {
        this.$router.push("/nursingDocument/combinedSheet");
      } else {
        this.$router.push("/nursingDocument/nurcareSheet");
      }
      this.initData();
    },
  },
  //过滤小数点后面的数
  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      if (value == 0 || value == "" || value == null) {
        return "";
      } else {
        let newstr = value;
        let leng = value.length - value.indexOf(".") - 1;
        if (value.indexOf(".") > -1) {
          for (let i = leng; i > 0; i--) {
            if (
              newstr.lastIndexOf("0") > -1 &&
              newstr.substr(newstr.length - 1, 1) == 0
            ) {
              let k = newstr.lastIndexOf("0");
              if (newstr.charAt(k - 1) == ".") {
                return newstr.substring(0, k - 1);
              } else {
                newstr = newstr.substring(0, k);
              }
            } else {
              return newstr;
            }
          }
        }
        return value;
      }
    }
  },
  methods: {
    //初始化数据
    initData() {
      const flag = this.selectPatientFlag();
      if (!flag) {
        Message({message: "请选择患者", type: "warning"});
        return;
      }

      //打开遮罩
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)",
      });
      this.loginInfo = this.$store.state.user.loginInfo;
      console.log(this.loginInfo)

      //赋值患者入科时间、赋值查询时间、赋值起始页码、赋值备注内容列表、赋值当前登录人名称、赋值初始化参数、查询患者参数、危急值
      //脉率状态
      this.entertime = this.data.enter_time.slice(0, 10);
      this.setInOutOrQueryDate(3);

      this.getCodeList();
      this.getPulseFlag();
      this.editIndex = -1;
      this.queryDataArray();
      loading.close(); //延时结束loading
      //关闭遮罩
    },

    isNullEmpty(data) {
      return isNullEmpty(data)
    },
    signFilter(val) {
      this.value = val;
      if (val) { //val存在
        this.signOptions = this.arrUserName.filter((item) => {
          if (item.user_name.indexOf(val) >= 0 || item.login_name.indexOf(val) >= 0) {
            return true
          }
        })
      } else { //val为空时，还原数组
        Object.assign(this.signOptions, this.arrUserName);
      }
    },
    //根据工号获取姓名
    getNameByJobNumber(number) {
      for (let i = 0; i < this.arrUserName.length; i++) {
        if (this.arrUserName[i].login_name == number) {
          return this.arrUserName[i].user_name;
        }
      }

      return number;
    },
    dateChange(row) {
      if (this.dateTimeCheck(row.index)) {
        this.tempDate = row.date;
        this.getUsedData(row.index);
        this.getUsedData(row, true);
      } else {
        row.date = this.tempDate;
      }
    },
    timeChange(row) {
      if (this.dateTimeCheck(row.index)) {
        this.tempTime = row.time;
        this.getUsedData(row, true);
      } else {
        row.time = this.tempTime;
      }
    },

    //新增或改变时间后，获取要沿用的监护仪数据
    getUsedData(item, timeChange) {
      var dtStr = item.date + " " + item.time + ":00";

      insertFlag({
          patientId: this.data.patient_id,
          timeChange: timeChange,
          dataTime: dtStr
        }
      ).then(
        (res) => {
          if (res.code == 200) {
            let tempData = res.data.data;

            item.hr = tempData.hr; //心率
            item.pulse = tempData.pulse; //脉搏
            item.br = tempData.br; //呼吸
            item.nbp = tempData.nbp; //有创
            item.abp = tempData.abp; //无创
            item.consciousness = tempData.consciousness; //意识
            item.pupilSizeLeft = tempData.pupilSizeLeft; //左
            item.pupilResponseLeft = tempData.pupilResponseLeft; //反应
            item.pupilSizeRight = tempData.pupilSizeRight; //大小
            item.pupilResponseRight = tempData.pupilResponseRight; //反应
            item.spO2 = tempData.spO2; //SpO₂(%)
          }
        }
      );
    },
    dateTimeCheck(index) {
      //判断录入时间是否大于当前时间
      var dtStr = this.dataArray[index].date + " " + this.dataArray[index].time + ":00";
      if (dateCompare(dtStr, dateUtils(2, new Date()))) {
        Message({message: '录入时间大于当前时间不能录入,请修改录入时间！', type: "warning"});
        return false
      }

      return true
    },
    //获取行编辑权限
    getRowEditPermission(curIndex, rowName = '') {
      if (this.editIndex != curIndex)
        return false

      //编辑按钮可操作
      if (rowName == 'editBtn')
        return true

      //编辑状态，本人不能签署护士签名
      if (this.editPermission == 1)
        return rowName == 'sign' ? false : true

      //编辑状态，非本人只能签署接班签名
      if (this.editPermission == 2)
        return rowName == 'secondSign' ? true : false

      return true
    },
    setEditPermission(data) {
      if (isNullEmpty(data.signWorkNo) || this.loginInfo.workNumber == 'admin' || this.loginInfo.roles[0] == '重症护士长') {
        this.editPermission = 0;
        return 0;
      }
      if (data.signWorkNo == this.loginInfo.workNumber) {
        this.editPermission = 1;
        return 1;
      } else {
        this.editPermission = 2;
        return 2;
      }
    },

    casChange(val) {
      //是否与上次的类型相同
      let changeFlag = false;
      let changeItem = null;
      if (this.casValueEnd.length === 0) {
        this.casValue = val;
      } else {
        //与原数组比对
        this.casValue.forEach((item) => {
          //与原数组的类型相同
          if (item[0] !== this.casValueEnd[0][0]) {
            changeFlag = true;
            changeItem = item;
          }
        });
      }
      if (changeFlag) {
        if (this.casValueEnd[0][0] === '✔') {
          this.casValue = this.casValue.filter((item) => {
            return (item[0] !== '✔');
          });
        } else {
          this.casValue = [];
          this.casValue.push(changeItem);
        }
      }
      this.casValueEnd = this.casValue;
    },
    //体温校验
    tiwenCheck(e, scope) {
      var y = String(e.target.value).indexOf(".") + 1; //获取小数点的位置
      var count = String(e.target.value).length - y; //获取小数点后的个数
      if (e.target.value >= 35 && e.target.value < 43) {
        if (y > 0) {
          if (count == 1) {
            scope.row.template = e.target.value;
          } else {
            Message({message: "体温的小数只能为一位", type: "warning"});
            return;
          }
        } else if (y == 0) {
          scope.row.template = e.target.value + ".0";
        } else {
          Message({message: "体温应该填写小数且小数为一位", type: "warning"});
          return;
        }
      } else {
        Message({message: "体温应该填写35-42的之间的小数,小数点有一位", type: "warning"});
      }
    },
    //心率校验
    xinlvCheck(e, scope) {
      if (e.target.value >= 0 && e.target.value < 161) {
        scope.row.hr = e.target.value;
      } else if (e.target.value.trim() == '测不出') {
        scope.row.hr = e.target.value.trim();
      } else {
        // scope.row.hr = "";
        Message({
          message: "心率应该填写0-160的之间的整数，或者测不出",
          type: "warning"
        });
      }
    },
    //脉率校验
    mailvCheck(e, scope) {
      if (
        e.target.value >= 0 &&
        e.target.value < 161 &&
        //e.target.value < scope.row.hr
        Number(e.target.value) < Number(scope.row.hr)
      ) {
        scope.row.pulse = e.target.value;
      } else if (e.target.value.trim() == '测不出') {
        scope.row.pulse = e.target.value.trim();
      } else {
        // scope.row.pulse = "";
        Message({
          message: "脉率应该填写0-160的之间的整数且小于心率,或者测不出",
          type: "warning"
        });
      }
    },
    //呼吸br校验
    huxiCheck(e, scope) {
      if (e.target.value >= 0 && e.target.value < 51) {
        scope.row.br = e.target.value;
      } else if (e.target.value.trim() == '测不出') {
        scope.row.br = e.target.value.trim();
      } else {
        // scope.row.br = "";
        Message({
          message: "呼吸应该填写0-50的之间的整数,或者测不出",
          type: "warning"
        });
      }
    },
    //无创血nbp压校验
    wuchuangCheck(e, scope) {
      var val = e.target.value.trim();
      var msg = this.mmHgCheck(val);

      if (msg == '') {
        scope.row.nbp = val;
      } else {
        // scope.row.nbp = "";
        Message({
          message: '无创血压' + msg,
          type: "warning"
        });
      }
    },
    //有创血压abp校验
    youchuangCheck(e, scope) {
      var val = e.target.value.trim();
      var msg = this.mmHgCheck(val);

      if (msg == '') {
        scope.row.abp = val;
      } else {
        // scope.row.abp = "";
        Message({
          message: '有创血压' + msg,
          type: "warning"
        });
      }
    },
    //血压输入值检测,返回错误提示
    mmHgCheck(val) {
      var msg = '';
      if (val == "测不出") {
        return msg;
      }

      var arr = val.split('/');
      var num1 = isNumber(arr[0]) ? Number(arr[0]) : NaN;
      var num2 = isNumber(arr[1]) ? Number(arr[1]) : NaN;

      // 输入数据必须有 '/'、同时为非数字、 或者其中一个为非数字但不为‘’,则进行错误提示
      if (arr.length != 2
        || (isNaN(num1) && isNaN(num2))
        || (isNaN(num1) && arr[0] != '')
        || (isNaN(num1) && arr[1] != '')) {
        msg = "请输入收缩压和舒张压。若只测出一个值，则在相应的位置输入符号/。例如：150/ 或 /150。";
        return msg;
      }
      //第一个为‘’时，判断第二个数字
      if (isNaN(num1) && arr[0] == '') {
        if (num2 < 10 || num2 > 200) {
          msg = '请输入正确的范围，30≤收缩压≤250的整数，10≤舒张压压≤200的整数。';
        }
        return msg;
      }
      //第二个为‘’时，判断第一个数字
      if (isNaN(num2) && arr[1] == '') {
        if (num1 < 30 || num1 > 250) {
          msg = '请输入正确的范围，30≤收缩压≤250的整数，10≤舒张压压≤200的整数。'
        }
        return msg;
      }
      //同时为数字时，需判断num1>num2,且输入范围正确
      if (num1 <= num2) {
        msg = '请检验格式，保证收缩压＞舒张压。';
      } else {
        if (num1 < 30 || num1 > 250 || num2 < 10 || num2 > 200) {
          msg = '请输入正确的范围，30≤收缩压≤250的整数，10≤舒张压压≤200的整数。';
        }
      }
      return msg;
    },
    //血糖值bloodGlucose校验
    xuetangCheck(e, scope) {
      var y = String(e.target.value).indexOf(".") + 1; //获取小数点的位置
      var count = String(e.target.value).length - y; //获取小数点后的个数

      if (e.target.value >= 0 && e.target.value < 36) {
        if (y > 0) {
          if (count == 1) {
            scope.row.bloodGlucose = e.target.value;
          } else {
            Message({message: "血糖值小数只能一位", type: "warning"});
            return;
          }
        } else if (y == 0 && e.target.value != "") {
          scope.row.bloodGlucose = e.target.value + ".0";
        } else {
          Message({message: "血糖值应该填写小数且小数为一位", type: "warning"});
          return;
        }
      } else {
        Message({
          message: "血糖值应该填写0-35的之间的小数,小数点有一位",
          type: "warning"
        });
      }
    },
    //SPO2校验
    SPO2Check(e, scope) {
      //判断是否在0-100之间，或者测不出
      if (e.target.value >= 0 && e.target.value < 101) {
        scope.row.spO2 = e.target.value;
      } else if (e.target.value.trim() == '测不出') {
        scope.row.spO2 = e.target.value.trim();
      } else {
        // scope.row.spO2 = "";
        Message({
          message: "SPO2应该填写0-100的之间的整数,或者测不出",
          type: "warning"
        });
      }
    },
    //cvp校验
    cvpCheck(e, scope) {
      if (e.target.value >= 0 && e.target.value < 21) {
        scope.row.cvp = e.target.value;
      } else {
        // scope.row.cvp = "";
        Message({
          message: "cvp应该填写0-20的之间的整数",
          type: "warning"
        });
      }
    },
    //fio2校验
    FIO2Check(e) {
      if (e.target.value < 21 || e.target.value > 100) {
        Message({message: "fio2应该填写21-100的之间的整数", type: "warning"});
      }
    },
    //氧流量oxygenFlow 校验
    yangliuliangCheck(e) {
      if (e.target.value < 1 || e.target.value > 15) {
        Message({message: "氧流量应该填写1-15的之间的整数", type: "warning"});
      }
    },

    addItem() {
      this.form.list.push({
        outPutName: "",
        outPutValue: "",
        outPutDictionaryId: ""
      });
    },
    addItemd() {
      this.form.pipeLengthList.push({
        pipeName: "",
        exposure: "",
        pipeLength: "",
        unobstructed: "",
        parts: '',
        liquidColor: ''
      });
    },
    deleteItem(item, index, length) {
      if (length == 1) {
        this.form.list = [{
          outPutName: "",
          outPutValue: "",
          outPutDictionaryId: ""
        },
        ];
      } else {
        this.form.list.splice(index, 1);
      }
    },
    deleteItemd(item, index, length) {
      if (length == 1) {
        this.form.pipeLengthList = [{
          pipeName: "",
          exposure: "",
          pipeLength: "",
          unobstructed: "",
          parts: '',
          liquidColor: ''
        },
        ];
      } else {
        this.form.pipeLengthList.splice(index, 1);
      }
    },
    //获得字典数据
    getCodeList() {
      getCombinedCodeList().then((res) => {
        if (res.code == 200 && res.data != null) {
          this.codeList = res.data;

          this.casOptions[0].children = this.codeList.ulcerCare;
          this.casOptions[1].children = this.codeList.ulcerCare;
        }
      });
    },
    //根据时间判断显示的时间  type=1小结时间  type=2 总结时间  type=3 查询时间
    setInOutOrQueryDate(type) {
      var toady = dateUtils(2, null);
      var compareDate = dateUtils(1, null) + " 08:30:00";
      var nextDate = new Date();
      nextDate.setTime(nextDate.getTime() + 24 * 60 * 60 * 1000);
      var topDate = new Date();
      topDate.setTime(topDate.getTime() - 24 * 60 * 60 * 1000);
      if (dateCompare(toady, compareDate)) {
        if (type == 1) {
          this.minSummaryData.beginDate = dateUtils(1, null) + " 07:00:00";
          this.minSummaryData.endDate = dateUtils(1, null) + " 19:00:00";
        } else if (type == 2) {
          this.summaryData.beginDate = dateUtils(1, null) + " 07:00:00";
          this.summaryData.endDate = dateUtils(1, nextDate) + " 07:00:00";
        } else if (type == 3) {
          this.queryDateTime[0] = dateUtils(1, null) + " 07:00:00";
          this.queryDateTime[1] = dateUtils(1, nextDate) + " 07:00:00";
        }
      } else {
        if (type == 1) {
          this.minSummaryData.beginDate = dateUtils(1, topDate) + " 07:00:00";
          this.minSummaryData.endDate = dateUtils(1, topDate) + " 19:00:00";
        } else if (type == 2) {
          this.summaryData.beginDate = dateUtils(1, topDate) + " 07:00:00";
          this.summaryData.endDate = dateUtils(1, null) + " 07:00:00";
        } else if (type == 3) {
          this.queryDateTime[0] = dateUtils(1, topDate) + " 07:00:00";
          this.queryDateTime[1] = dateUtils(1, null) + " 07:00:00";
        }
      }
    },
    //判断是否选择患者
    selectPatientFlag() {
      this.data = this.$store.state.user.severFall;
      if (this.data.patient_id == undefined) {
        return false;
      }
      return true;
    },
    selectTypeList() {
      getListlei({
        status: 1,
      }).then((res) => {
        this.arrTypelist = res.data;
        for (let i = 0; i < this.arrTypelist.length; i++) {
          if (this.arrTypelist[i].dict_template_name == "自定义出量") {
            this.templateType.push(this.arrTypelist[i]);
          }
          if (this.arrTypelist[i].dict_template_name == "自定义引流管") {
            this.templateTypes.push(this.arrTypelist[i]);
          }
        }
      });
    },
    throughputd(item) {
      let list = this.templateTypes;
      let temp;
      for (let i = 0; i < list.length; i++) {
        if (item.pipeName == list[i].template_item_name) {
          if (list[i].especially_identifying == '1') {
            temp = '置入'
          } else if (list[i].especially_identifying == '2') {
            temp = '外露'
          } else {
            temp = '';
          }
          item.exposure = temp;
        }
      }
    },

    //初始化脉率状态
    getPulseFlag() {
      queryDataMaibo({
        id: this.data.patient_id,
      }).then((res) => {
        if (res.code == 200) {
          this.pulseFlag = res.data.isOpenPulseRecord;
        }
      });
    },
    //=====================初始化end================================

    //=====================功能项==============================
    //==========================小结、总结begin=======================
    //打开小结、总结页面
    openSummaryOrSummarizePage(flag) {
      if (flag == "小结") {
        this.summaryDialog = true;
        this.setInOutOrQueryDate(1);
      } else if (flag == "总结") {
        this.summarizeDialog = true;
        this.setInOutOrQueryDate(2);
      }
    },
    summaryOrsummarizeClick(flag) {
      //小结、总结计算不算第一条数据,此方案不行
      getCombinedSheetSummaryOrSummarize({
        patientId: this.data.patient_id,
        startTime: flag == "小结" ? this.minSummaryData.beginDate : this.summaryData.beginDate,
        endTime: flag == "小结" ? this.minSummaryData.endDate : this.summaryData.endDate,
        surplus: flag == "小结" ? this.minSummaryData.surplus : this.summaryData.surplus,
        type: flag == "小结" ? this.minSummaryData.type : this.summaryData.type,
        flag: flag,
      }).then((res) => {
        if (res.code == 200) {
          if (flag == "小结") {
            this.summaryDialog = false;
          } else if (flag == "总结") {
            this.summarizeDialog = false;
          }
          Message({message: flag + "成功", type: "success"});
          this.queryDataArray();
        } else {
          Message({message: flag + "失败", type: "warning"});
        }
      });
    },
    //小结、总结取消
    summaryOrSummarizeCancel(flag) {
      if (flag == "小结") {
        this.summaryDialog = false;
      } else if (flag == "总结") {
        this.summarizeDialog = false;
      }
    },
    summaryOrsummarizeqClick() {
      let list = this.form.list;

      this.panto = [];

      //弹窗为空保存数据时，清除数据
      if (list.length == 1 && list[0].outPutName == "" && list[0].outPutValue == "") {
        this.dataArray[this.rowIndex].otherOutNum = '';
        this.$set(this.dataArray, this.rowIndex, this.dataArray[this.rowIndex]);
        this.summaryq = false;
        return;
      }

      for (let zz = 0; zz < list.length; zz++) {
        //排除出量名称相同
        for (let i = zz + 1; i < list.length; i++) {
          if (list[zz].outPutName == list[i].outPutName) {
            alert("出量名称不能相同");
            return;
          }
        }

        if (list[zz].outPutName == "") {
          alert("出量名称不能为空");
          return;
        } else if (list[zz].outPutValue == "") {
          alert("出量值不能为空");
          return;
        }

        this.panto.push(list[zz].outPutName + ":" + list[zz].outPutValue + "ml;");
      }
      this.dataArray[this.rowIndex].otherOutNum = this.panto.join("").replace(/;/g, "\n");
      this.summaryq = false;
    },
    summaryOrsummarizedClick() {
      this.panto = [];
      let temp, exposure, pipeLength;
      let list = this.form.pipeLengthList;

      //导管列表为空时保存，清空数据
      if (list.length == 1 && list[0].pipeName == "" && list[0].pipeLength == "") {
        this.dataArray[this.rowIndex].pipeLength = '';
        this.$set(this.dataArray, this.rowIndex, this.dataArray[this.rowIndex]);
        this.summaryd = false;
        return;
      }

      for (let zz = 0; zz < list.length; zz++) {
        let tempPipe = [];

        if (list[zz].pipeName == "") {
          alert("导管名称不能为空");
          return;
        }

        //格式要求 胃管（置入）12cm/√/外周/淡黄色
        exposure = list[zz].exposure == '' ? '' : "(" + list[zz].exposure + ")";
        pipeLength = list[zz].pipeLength == '' ? '' : list[zz].pipeLength + "cm";
        temp = list[zz].pipeName + exposure + pipeLength;
        tempPipe.push(temp)
        isNullEmpty(list[zz].unobstructed) ? '' : tempPipe.push(list[zz].unobstructed)
        isNullEmpty(list[zz].parts) ? '' : tempPipe.push(list[zz].parts)
        isNullEmpty(list[zz].liquidColor) ? '' : tempPipe.push(list[zz].liquidColor)

        this.panto.push(tempPipe.join('/') + ';');
      }
      this.dataArray[this.rowIndex].pipeLength = this.panto.join("").replace(/;/g, "\n");
      this.summaryd = false;
    },
    //添加空数据行，无实质内容，除了时间和签名
    addEmptyRow() {
      const flag = this.selectPatientFlag();
      if (!flag) {
        Message({message: "请选择患者", type: "warning"});
        return;
      }
      if (this.editIndex >= 0) {
        Message({message: "前次编辑未结束!", type: "warning"});
        return;
      }
      if (typeof this.dataArray != "undefined") {
        var item = {
          id: "", // 主键ID
          visitId: "", //  住院号
          visitCode: "", // 本次住院号
          patientId: "", // 病人主键id
          parentId: "", // 关联父级id
          dataTime: "", // 记录时间;

          status: 1,
          index: 0,
          date: "",
          time: "",
          consciousness: "", //意识
          pupilSizeLeft: "", //瞳孔大小左
          pupilResponseLeft: "", //对光反应左
          pupilSizeRight: "", //瞳孔大小右
          pupilResponseRight: "", //对光大小右
          template: "", //体温
          hr: "", // 心率
          pulse: "", // 脉率;
          br: "", // 呼吸
          abp: "", // 有创血压
          nbp: "", // 无创血压;
          spO2: "", // SPO2
          heartRhythm: "", // 心律;
          cvp: "", // CVP;
          oxygenMode: "", // 吸氧方式;
          oxygenFlow: "", // 氧流量(L/分);
          mode: "", // 模式;
          fio2: "", //  FiO2(%);
          vt: "", // 潮气量vt手动设置i吸入,vte呼出，暂为吸入;
          f: "", // 通气频率手动设置;
          pc: "", // 压控模式或压控模式时的吸气压力;
          ps: "", // 压力支持模式（也称 PSV），或压力支持模式时的吸气压力;
          peep: "", // 呼气末正压;
          ipap: "", // IPAP指的是吸气压力;
          epap: "", // EPAP指的是呼气压力;
          sputum: false, // 痰液;
          sputumInde: "", // 痰液分度;
          bloodGlucose: "", // 血糖
          nurseActivity: false, //翻身
          bodyPosition: "", // 体位;
          nurseMeasure: "", // 护理措施;
          nurseSkin: "", // 护理皮肤;
          pipeLength: "", // 导管/长度;
          pipeReuse: '', //管路情况
          medicineContent: "", // 药物内容;
          noseMouth: "", // 鼻饲口服;
          intravenous: "", // 静脉;
          otherInNum: "", //入量其它
          totalAmount: "", // 总入量
          urine: "", // 小便;
          excrement: "", // 大便;
          otherOutNum: "", // 出量其它;
          outputAmount: "", // 出量总量;
          result: "", // 病情观察、治疗、护理措施及效果;
          sign: "", // 签名1;
          secondSign: "", // 签名2;
          signWorkNo: '',  //护士签名工号,
          successorWorkNo: '', //接班签名工号
          flag: "", // 总结小结标识;
        };

        if (this.dataArray.length > 0) {
          item.index = this.dataArray.length;
        } else {
          item.index = 0;
        }
        this.form = {
          rowId: "",
          patientId: "",
          list: [
            {
              outPutName: "",
              outPutValue: "",
              outPutDictionaryId: ""
            },
          ],
          pipeLengthList: [
            {
              pipeName: "",
              exposure: "",
              pipeLength: "",
              unobstructed: "",
              parts: '',
              liquidColor: ''
            },
          ],
        };

        var date = new Date();
        item.date = dateUtils(1, date);
        item.time = dateUtils(8, date);
        this.tempDate = item.date;
        this.tempTime = item.time;

        item.sign = this.getNameByJobNumber(this.loginInfo.workNumber);
        item.signWorkNo = this.loginInfo.workNumber; //护士签名工号

        //新增时数据清空
        this.casValue = '';
        this.casValueEnd = '';

        this.setEditPermission(item);

        this.getUsedData(item)

        this.dataArray.push(item);
        this.editIndex = item.index;
        //滚到最后
        this.$nextTick(() => {
          let container = this.$el.querySelector(".el-table__body-wrapper");
          container.scrollTop = container.scrollHeight;
        });
        this.$forceUpdate();
      }
    },

    //双击将当前的序号放入数据中
    cellClassName({row, column, columnIndex}) {
      column.index = columnIndex;
    },
    tableRowClassName({row, rowIndex}) {
      //把每一行的索引放进row
      row.index = rowIndex;
    },

    //双击行数据进行编辑
    rowDbClick(row) {
      //判断是否允许双击(小结数据不允许双击)
      if (row.flag) return;

      //行数据编辑初始化
      this.editRowDataInit(row.index, row);
    },
    editRowDataInit(index, rowData) {
      var editData = this.dataArray[index];

      if (this.editIndex >= 0) {
        Message({message: "前次编辑未结束!", type: "warning"});
        return;
      }

      if (this.setEditPermission(rowData) == 2) {
        Message({message: "您只能编辑接班签名!", type: "info"});
      }

      //护士签名为空（自动同步的数据）,编辑时将签名改为当前账户签名
      if (isNullEmpty(rowData.signWorkNo)) {
        rowData.sign = this.getNameByJobNumber(this.loginInfo.workNumber);
        rowData.signWorkNo = this.loginInfo.workNumber;
      }

      this.orderID = null;
      this.orderTime = null;

      //获取 其他和导管 的数据
      this.getOtherData(rowData.id);
      this.getCatheterData(rowData.id);

      //保存旧数据
      this.lastRowData = JSON.parse(JSON.stringify(editData));

      //多选字段，字符串转数组
      editData.bodyPosition = editData.bodyPosition == null ? '' : editData.bodyPosition.split(",");
      editData.nurseMeasure = editData.nurseMeasure == null ? '' : editData.nurseMeasure.split(",");
      // editData.nurseSkin = this.setNurseSkin(editData.nurseSkin);
      this.casValue = editData.nurseSkin == null ? '' : this.setNurseSkin(editData.nurseSkin);

      this.editIndex = index;
    },

    //删除
    deleteButtonClick(index, row) {
      if (this.editIndex >= 0) {
        Message({
          message: "前次编辑未结束!",
          type: "warning",
          duration: 1500,
        });
        return;
      }

      if (!confirm("确认删除吗?")) return;
      getCombinedSheetDelete({
        id: this.dataArray[index].id,
      }).then((res) => {
        this.$message({
          message: res.msg,
          type: "success",
        });
        if (res.code == '200') {
          this.queryDataArray();
        }
      });

      this.editIndex = -1;
    },
    //将字符串转成数字
    getIntValue(str) {
      if (typeof str != "string" || str.length < 1) {
        return 0.0;
      } else {
        str = str.trim();
        return parseFloat(str);
      }
    },
    //保存
    saveButtonClick(indexOne, index) {
      if (index < 0) return;
      this.insertRow(index);
    },
    //取消保存
    reverseButtonClick(index) {
      if (index < 0) return;
      if (
        JSON.stringify(this.dataArray[index]) !=
        JSON.stringify(this.lastRowData)
      ) {
        //if (!this.isEmptyRow(index)) {
        if (!confirm("确认放弃修改, 恢复原值吗?")) return;
        //}
      }
      this.$set(this.dataArray, index, this.lastRowData);
      document.body.style.setProperty(
        "--editRowHeight",
        this.editRowHeight + "px"
      );
      this.queryDataArray();
      // this.editIndex = -1;
    },
    //插入数据
    insertRow(index) {
      let rowData = this.dataArray[index];
      this.form.rowId = rowData.id;
      this.form.patientId = this.data.patient_id;

      //判断录入时间是否大于当前时间
      var dtStr = rowData.date + " " + rowData.time + ":00";
      if (dateCompare(dtStr, dateUtils(2, new Date()))) {
        alert("录入时间大于当前时间不能录入,请修改录入时间！！");
        return;
      }

      this.editIndex = -1;
      this.data = this.$store.state.user.severFall;

      console.log(rowData, 'insert');
      getCombinedSheetInsert({
        status: "1",
        flag: rowData.flag,
        orderId: this.orderID,
        orderTime: this.orderTime,

        id: rowData.id,
        visitId: this.data.visit_id,
        visitCode: this.data.visit_code,
        patientId: this.data.patient_id,
        parentId: rowData.parentId,
        dataTime: dtStr,

        time: rowData.time,
        date: rowData.date,
        consciousness: rowData.consciousness,
        pupilSizeLeft: rowData.pupilSizeLeft,
        pupilResponseLeft: rowData.pupilResponseLeft,
        pupilSizeRight: rowData.pupilSizeRight,
        pupilResponseRight: rowData.pupilResponseRight,

        template: rowData.template,
        hr: rowData.hr,
        pulse: rowData.pulse,
        br: rowData.br,
        abp: rowData.abp,
        nbp: rowData.nbp,
        spO2: rowData.spO2,

        heartRhythm: rowData.heartRhythm,
        cvp: rowData.cvp,

        oxygenMode: rowData.oxygenMode,
        oxygenFlow: rowData.oxygenFlow,
        mode: rowData.mode,
        fio2: rowData.fio2,
        vt: rowData.vt,
        f: rowData.f,
        pc: rowData.pc,
        ps: rowData.ps,
        peep: rowData.peep,
        ipap: rowData.ipap,
        epap: rowData.epap,
        sputum: rowData.sputum,
        sputumInde: rowData.sputumInde,

        bloodGlucose: rowData.bloodGlucose,
        nurseActivity: rowData.nurseActivity,

        bodyPosition: rowData.bodyPosition.join(','),
        nurseMeasure: rowData.nurseMeasure.join(','),
        nurseSkin: this.getNurseSkin(rowData.nurseSkin),

        pipeLength: rowData.pipeLength == "" ? "" : rowData.pipeLength,
        pipeReuse: rowData.pipeReuse,
        medicineContent: rowData.medicineContent,

        noseMouth: this.getIntValue(rowData.noseMouth),
        intravenous: this.getIntValue(rowData.intravenous),
        otherInNum: this.getIntValue(rowData.otherInNum),
        totalAmount: this.getIntValue(rowData.totalAmount),
        urine: this.getIntValue(rowData.urine),
        excrement: this.getIntValue(rowData.excrement),
        otherOutNum: rowData.otherOutNum,
        outputAmount: this.getIntValue(rowData.outputAmount),

        result: rowData.result,
        sign: this.getNameByJobNumber(rowData.signWorkNo),
        secondSign: this.getNameByJobNumber(rowData.successorWorkNo),
        signWorkNo: rowData.signWorkNo,
        successorWorkNo: rowData.successorWorkNo,

        vp: rowData.vp,
        nurseRecordFormDto: this.form,
      }).then((res) => {
        if (res.code == 200) {
          this.editIndex = -1;

          //保存成功后清空表单数据
          this.form = {
            rowId: "",
            patientId: "",
            list: [
              {
                outPutName: "",
                outPutValue: "",
                outPutDictionaryId: ""
              },
            ],
            pipeLengthList: [
              {
                pipeName: "",
                exposure: "",
                pipeLength: "",
                unobstructed: "",
                parts: '',
                liquidColor: ''
              },
            ],
          };

          this.queryDataArray();
        } else {
          Message({
            message: res.msg,
            type: "warning",
            duration: 1500,
          });
        }
      });
    },
    //====================查询===================================
    //查询
    queryDataArray() {
      if (this.queryDateTime[0] == "" || this.queryDateTime[1] == "") {
        Message({message: "开始和结束时间不能为空!", type: "warning"});
        return;
      }

      getCombinedSheetList({
        patientId: this.data.patient_id,
        startTime: this.queryDateTime[0],
        endTime: this.queryDateTime[1],
        hour: 100
      })
        .then((res) => {
          if (res.data) {
            this.dataArray = res.data;
            this.queryLoading = false;
            this.editIndex = -1;
          } else {
            this.dataAarray = [];
            this.queryLoading = false;
            this.editIndex = -1;
          }
        })
        .catch((err) => {
          this.queryLoading = false;
        });
    },

    //====================打印===================================
    //打印当前页
    printAllButtonClick() {
      let thus = this;

      getCombinedSheetList({
        patientId: this.data.patient_id,
        startTime: this.queryDateTime[0],
        endTime: this.queryDateTime[1]
      }).then((res) => {
        if (res.data) {
          thus.printArray = res.data;

          thus.$nextTick(function () {
            thus.printOut();
          });
        } else {
          this.loading = false;
          this.printAarray = [];
          Message({message: "未查询到打印数据!", type: "warning"});
        }
      })
    },
    printOut() {
      jyxdPrint(this.printParam);
      this.printArray = [];
    },
    /**
     // 每页显示的条数
     handleSizeChange(val) {
     this.PageSize = val;
     this.start = 1;
     this.queryPageAndPrintAllCommon(val, this.start);
     },
     // 显示第几页
     handleCurrentChange(val) {
     this.start = val;
     this.queryPageAndPrintAllCommon(this.PageSize, this.start);
     },
     **/
    //打印分页查询end=============================================

    cellStyle(row, column, rowIndex, columnIndex) {
      //根据报警级别显示颜色
      if (row.row.flag === "小结") {
        return "background:blue;color: white";
      } else if (row.row.flag === "总结") {
        return "background:red;color: white";
      }
    },
    //脉搏开启
    updatePulseFlag() {
      openPulseRecord({
        patientId: this.data.patient_id,
        openStatus: this.pulseFlag,
      }).then((res) => {
        if (this.data.patient_id) {
          Message({
            message: "修改成功",
            type: "success",
            duration: 1500,
          });
        } else {
          Message({
            message: "修改失败",
            type: "warning",
            duration: 1500,
          });
        }
      });
    },

    //==================行数据处理===========================
    //皮肤 str转数组
    setNurseSkin(arr) {
      if (arr.length == 0)
        return []

      let temp = arr.split('/');
      let char = temp[0];
      let option = temp[1].split(',');

      //定义二维数组
      let tempArr = new Array(option.length).fill('').map(() => new Array(char));
      option.forEach((item, i) => {
        tempArr[i].push(item);
      })

      return tempArr
    },
    //皮肤 数组转str
    getNurseSkin() {
      if (this.casValue.length == 0)
        return ''

      let char = this.casValue[0][0];
      let tempArr = [];
      this.casValue.forEach((item) => {
        tempArr.push(item[1])
      })

      return char + '/' + tempArr.join(',')
    },
    //药物名称
    selectOrderName(index) {
      this.orderIndex = index;
      this.dialogVisible = true;
    },
    //双击选择护理措施模板
    selectTemplate(row, index) {
      this.nursingMeasuresDialog = true;
      this.rowIndex = index;
    },
    //双击其它
    selectTemplateq(scope, index) {
      this.summaryq = true;
      this.rowIndex = index;
    },
    //获取其它列的数据
    getOtherData(rowId) {
      nurseRecordFormOutPutqueryList({
        rowId: rowId,
      }).then((res) => {
        if (res.data.length > 0) {
          this.form.list = res.data;
        } else {
          this.form.list = [
            {
              outPutName: "",
              outPutValue: "",
              outPutDictionaryId: ""
            },
          ];
        }
      });
    },
    //获取导管列的数据
    getCatheterData(rowId) {
      nurseRecordFormPipeLengthQueryList({
        rowId: rowId,
      }).then((res) => {
        if (res.data.length > 0) {
          this.form.pipeLengthList = res.data;
        } else {
          this.form.pipeLengthList = [
            {
              pipeName: "",
              exposure: "",
              pipeLength: "",
              unobstructed: "",
              parts: '',
              liquidColor: ''
            },
          ];
        }
      });
    },
    //双击导管
    selectTemplated(scope, index) {
      this.summaryd = true;
      this.rowIndex = index;
    },
    handleClose(done) {
      done();
    },
    //同步
    processDate() {
      this.synchronizeDialog = true;
      getCommonSettingByPatientId({
        patientId: this.data.patient_id,
        settingType: "NursingSynLifeType",
      }).then((res) => {
        if (res.code == 200 && res.data != null) {
          this.synchronizeBeginDate = res.data.beginTime;
          this.synchronizeEndDate = res.data.endTime;
          this.frequency = res.data.settingContent;
          this.statusover = res.data.onOff == 'true' ? true : false;
          this.idsss = res.data.id;
        } else {
          this.synchronizeBeginDate = "";
          this.synchronizeEndDate = "";
          this.frequency = "";
          this.statusover = false;
          this.idsss = "";
        }
      });
    },
    //同步生命体征弹窗保存
    synchronizeSave() {
      NursingUpdateOnOrOff({
        patientId: this.data.patient_id,
        beginTime: this.synchronizeBeginDate,
        endTime: this.synchronizeEndDate,
        settingContent: this.frequency,
        settingType: "NursingSynLifeType",
        onOff: this.statusover ? 'true' : 'false',
        id: this.idsss,
      }).then((res) => {
        if (res.code == 200) {
          this.synchronizeDialog = false;
          Message({message: "保存成功", type: "success"});
        } else {
          this.synchronizeDialog = true;
          Message({message: "保存失败", type: "warning"});
        }
      });
    },
    //同步生命体征弹窗取消
    synchronizeSaveCancel() {
      this.synchronizeDialog = false;
      this.synchronizeBeginDate = "";
      this.synchronizeEndDate = "";
      this.frequency = "";
      this.statusover = false;
      this.idsss = "";
    },
    //同步生命体征状态改变
    syncStatechange() {
      if (this.statusover) {
        if (this.synchronizeBeginDate == '' || this.synchronizeEndDate == '' || this.frequency == '') {
          Message({
            message: "状态开启时,必须输入时间和频率！",
            type: "warning"
          });

          this.statusover = false;
          return;
        }
      }
    },
    //多行文本输入自动调整行高
    textAreaChanging(ev, index) {
      document.body.style.setProperty(
        "--editRowHeight",
        ev.target.scrollHeight + "px"
      );
    },
    formatSpO2(val) {
      if (val == "" || val == null) {
        return "";
      } else if (val == '测不出') {
        return val;
      } else {
        return Math.floor(parseFloat(val));
      }
    },
    formatDate(dateObject) {
      if (!dateObject) return '';

      const year = dateObject.year;
      const month = dateObject.monthValue.toString().padStart(2, '0');
      const day = dateObject.dayOfMonth.toString().padStart(2, '0');
      const hour = dateObject.hour.toString().padStart(2, '0');
      const minute = dateObject.minute.toString().padStart(2, '0');
      const second = dateObject.second.toString().padStart(2, '0');

      return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    },
    handleMouseOver(event) {
      const rowElement = event.target.closest('tr');
      if (rowElement) {
        //判断是否在表头
        if (rowElement.closest('thead') !== null) {
          console.log('表头')
          this.hoverRowIndex = -1;
          return;
        }
        console.log('表行', rowElement.rowIndex)
        this.hoverRowIndex = rowElement.rowIndex;
      }
    },
    handleMouseOut() {
      clearTimeout(this.hoverTimer);
    },
    //上次修改人弹窗关闭
    handleClose2(done) {
      this.hoverDialogVisible = false;
      this.historyRowId = "";
      this.hoverRowInfo = '';
      done();
    },
    //历史修改弹窗关闭
    handleClose3(done) {
      this.hoverDetailsDialogVisible = false;
      this.historyRowId = "";
      this.updateLogArr = [];
      done();
    },
    //查询历史修改信息
    HistoryUpdate() {
      getNurLogs(this.historyRowId).then(res => {
        this.updateLogArr = res.data.map(item => {
          const updateJsonObj = JSON.parse(item.updateJson)
          return {
            userName: item.userName,
            updateTime: item.updateTime,
            date: updateJsonObj.date,
            time: updateJsonObj.time,
            consciousness: updateJsonObj.consciousness,
            pupilSizeLeft: updateJsonObj.pupilSizeLeft,
            pupilResponseLeft: updateJsonObj.pupilResponseLeft,
            pupilSizeRight: updateJsonObj.pupilSizeRight,
            pupilResponseRight: updateJsonObj.pupilResponseRight,
            template: updateJsonObj.template,
            hr: updateJsonObj.hr,
            pulse: updateJsonObj.pulse,
            br: updateJsonObj.br,
            abp: updateJsonObj.abp,
          }
        });
        this.hoverDialogVisible = false;
        this.hoverDetailsDialogVisible = true
      })
    },
    handleKeyDown(event) {
      if (event.ctrlKey && event.key === 'q') {
        if (this.hoverRowIndex !== null && this.hoverRowIndex !== -1) {
          const row = this.dataArray[this.hoverRowIndex];
          console.log('当前行对象:', row);
          console.log('按键对象:', event);
          // 检查当前行是否在编辑状态
          const isEditing = this.getRowEditPermission(this.hoverRowIndex, 'editBtn');

          if (isEditing) {
            console.log("当前行正在编辑")
          } else {
            this.historyRowId = row.id;
            getNurLog(row.id).then(res => {
              if (res.data) {
                this.hoverRowInfo = `上次修改人: ${res.data.userName},修改时间: ${this.formatDate(res.data.updateTime)}`;
              } else {
                this.hoverRowInfo = '暂无修改信息';
              }
              this.hoverDialogVisible = true;
            })
          }
        }
      }
    }
  },
};
</script>
<style lang="scss" scoped>
.nur-doc-sheet {
  .head-info {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    line-height: 40px;
    padding: 10px;

    ::v-deep .el-icon-time, ::v-deep .el-range-separator {
      line-height: 32px;
    }
  }

  ::v-deep .el-table__body-wrapper {
    overflow-y: auto;
  }

  ::v-deep .el-input__inner {
    padding: 0px;
    padding-left: 2px;
  }

  ::v-deep .el-input__prefix {
    display: none;
  }

  ::v-deep .el-table .cell {
    white-space: pre-line;
    padding: 0;
  }
}

.sync-dialog {
  line-height: 60px;

  .label {
    display: inline-block;
    width: 120px;
    text-align: right;
  }

  ::v-deep .el-input--small {
    width: 220px;
  }
}

.pipe-dialog {
  ::v-deep .el-dialog__body {
    padding: 0 20px;
  }
}
</style>
